-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieve mandatory email address from Github #129
Conversation
The /user API returns only the data the user explicitly set as public and null for those he didn't. If the user did not set the email address public (me for example), the email address being mandatory for the process, the authentication fails returning an error message. By using the /user/emails API in conjunction, it is possible to retrieve all the email addresses the user set in Github, regardless if they are set public or not, and select one of those (ex: primary one), for the login process to complete successfully.
…-Github The /user API returns only the data the user explicitly set as public and null for those he didn't. If the user did not set the email address public (me for example), the email address being mandatory for the process, the authentication fails returning an error message. By using the /user/emails API in conjunction, it is possible to retrieve all the email addresses the user set in Github, regardless if they are set public or not, and select one of those (ex: primary one), for the login process to complete successfully.
WalkthroughThe updates to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/Libraries/GithubOAuth.php (2 hunks)
Additional comments not posted (3)
src/Libraries/GithubOAuth.php (3)
107-124
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
fetchUserEmailsWithToken
are correctly handled.Verification successful
LGTM! But verify the function usage in the codebase.
The code changes are approved.
The function
fetchUserEmailsWithToken
is used correctly within the same file and is properly handled by thegetUserPrimaryEmail
method. No further issues were found.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `fetchUserEmailsWithToken` are correctly handled. # Test: Search for the function usage. Expect: Proper handling of the function calls. rg --type php -A 5 $'fetchUserEmailsWithToken'Length of output: 773
Script:
#!/bin/bash # Description: Verify all function calls to `getUserPrimaryEmail` are correctly handled. # Test: Search for the function usage. Expect: Proper handling of the function calls. rg --type php -A 5 $'getUserPrimaryEmail'Length of output: 963
129-135
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
getUserPrimaryEmail
are correctly handled.Verification successful
Verify the implementation of
$this->fetchUserEmailsWithToken()
and the$userInfo
object.The function
getUserPrimaryEmail
is used to assign the primary email address to$userInfo->email
. To ensure proper handling, verify the implementation of$this->fetchUserEmailsWithToken()
and the$userInfo
object.
Verification successful: Proper handling of
getUserPrimaryEmail
function usage.The function
getUserPrimaryEmail
is correctly handled in the codebase. The implementation offetchUserEmailsWithToken
and the handling of the$userInfo
object are appropriate and ensure the correct functionality.
- The
fetchUserEmailsWithToken
function is implemented to retrieve user emails from an API.- The
$userInfo
object is properly utilized to handle user information, including setting the primary email.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `getUserPrimaryEmail` are correctly handled. # Test: Search for the function usage. Expect: Proper handling of the function calls. rg --type php -A 5 $'getUserPrimaryEmail'Length of output: 963
Script:
#!/bin/bash # Description: Verify the implementation of fetchUserEmailsWithToken and the userInfo object. # Test: Search for the implementation of fetchUserEmailsWithToken. Expect: Proper implementation. rg --type php -A 5 $'fetchUserEmailsWithToken' # Test: Search for the definition and usage of $userInfo. Expect: Proper handling of the object. rg --type php -A 5 $'userInfo'Length of output: 9906
94-101
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
fetchUserInfoWithToken
are correctly handled.Verification successful
To ensure that the function
fetchUserInfoWithToken
is correctly handled across the codebase, we need to verify its usage in theAbstractOAuth.php
class and how it is overridden inGithubOAuth.php
andGoogleOAuth.php
.
To ensure the changes in
GithubOAuth.php
are correctly handled, we need to retrieve the full method inAbstractOAuth.php
that callsfetchUserInfoWithToken
.
To retrieve the full method in
AbstractOAuth.php
that callsfetchUserInfoWithToken
, we will userg
to search for the method definition and its surrounding context.
To ensure that the changes in
GithubOAuth.php
are correctly integrated, we need to confirm that thegetUserInfo
method inAbstractOAuth.php
is used correctly in the codebase.
Function usage is correctly handled.
The changes in
GithubOAuth.php
ensure that a valid email address is always retrieved, which is critical for the logic inOAuthController.php
. This confirms that the changes are correctly integrated and handled in the codebase.
OAuthController.php
: ThegetUserInfo
method is used to retrieve user information, which includes the mandatory email address.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `fetchUserInfoWithToken` are correctly handled. # Test: Search for the function usage. Expect: Proper handling of the function calls. rg --type php -A 5 $'fetchUserInfoWithToken'Length of output: 2158
Script:
#!/bin/bash # Verify the context in AbstractOAuth.php where fetchUserInfoWithToken is called rg --type php -A 10 $'fetchUserInfoWithToken' src/Libraries/Basic/AbstractOAuth.php # Check how fetchUserInfoWithToken is overridden in GithubOAuth.php and GoogleOAuth.php rg --type php -A 10 $'fetchUserInfoWithToken' src/Libraries/GithubOAuth.php rg --type php -A 10 $'fetchUserInfoWithToken' src/Libraries/GoogleOAuth.phpLength of output: 1743
Script:
#!/bin/bash # Retrieve the full method in AbstractOAuth.php that calls fetchUserInfoWithToken ast-grep --lang php --pattern $'abstract class AbstractOAuth { $$$ protected function $_($_) { $$$ return $this->fetchUserInfoWithToken(); $$$ } $$$ }' src/Libraries/Basic/AbstractOAuth.phpLength of output: 317
Script:
#!/bin/bash # Retrieve the full method in AbstractOAuth.php that calls fetchUserInfoWithToken rg --type php -A 20 $'fetchUserInfoWithToken' src/Libraries/Basic/AbstractOAuth.phpLength of output: 760
Script:
#!/bin/bash # Verify the usage of getUserInfo method in the codebase rg --type php -A 10 $'getUserInfo' src/Length of output: 1590
The /user API returns only the data the user explicitly set as public and null for those he didn't.
If the user did not set the email address public (me for example), the email address being mandatory for the process, the authentication fails returning an error message.
By using the /user/emails API in conjunction, it is possible to retrieve all the email addresses the user set in Github, regardless if they are set public or not, and select one of those (ex: primary one), for the login process to complete successfully.
Summary by CodeRabbit
New Features
Improvements