Skip to content
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

Login with GitHub error after changing email #174

Open
iimog opened this issue Mar 28, 2018 · 1 comment
Open

Login with GitHub error after changing email #174

iimog opened this issue Mar 28, 2018 · 1 comment
Labels
Projects
Milestone

Comments

@iimog
Copy link
Member

iimog commented Mar 28, 2018

If you login to Fennec using GitHub and then change the (primary) email address of your account. All future login attempts will fail. As the emails do not match Fennec thinks it is a new user but can not create that user because the username already exists.

@iimog iimog added the bug label Mar 28, 2018
@sonjafeitsch
Copy link
Collaborator

sonjafeitsch commented Mar 30, 2018

The related function loadUserByOAuthUserResponse() in src/AppBundle/Security/Core/user/FOSUBUserProvider.php gets the current user from the OAuth response.

At the moment we are saving the email address and username from the response. It is important to know that here the username is NOT the nickname of the Fennec user but an identifier like 123456789.

If the user has changed his email, we check if there is an user with the username 123456789 which is not found. Instead we could replace the username by the nickname which is described in the following example. Then it is possible to login with github after the email address has changed.

public function loadUserByOAuthUserResponse(UserResponseInterface $response)
    {
        $userEmail = $response->getEmail();

        //change the following line to $username = $response->getNickname()
        $username = $response->getUsername();

        //if the user has changed his email adress $user is null
        $user = $this->userManager->findUserByEmail($userEmail);

        //check if we can find a Fennec user related to the username of the github user
        if(null === $user){
            $user = $this->userManager->findUserByUsername($username);
        }
        //if null create new user and set its properties
        if(null === $user){
              ...
        }
        //get service and update access token
        return $user;
    }

Probably this will not work if the user changes his email address and its username... so we should discuss and think about changing the structure of this function 🙂

@iimog iimog added this to the 1.1.0 milestone Apr 3, 2018
@iimog iimog added this to Ideas in post 1.0.0 Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
post 1.0.0
  
Ideas
Development

No branches or pull requests

2 participants