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

fix login remember me with google authentication #740

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Controller/Traits/LoginTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ public function verify()

$user['secret_verified'] = true;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Push the remember me value to post data
// for after login event auth
$hasRememberMe = $this->request->getSession()->read('hasRememberMe');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a namespace key like Users.hasRememberMe

if ($hasRememberMe) {
$this->request->data(Configure::read('Users.RememberMe.Cookie.name'), $hasRememberMe);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a unit test for this

$this->request->getSession()->delete('hasRememberMe');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a namespace key like Users.hasRememberMe

}

$this->request->getSession()->delete('temporarySession');
$this->Auth->setUser($user);
Expand Down Expand Up @@ -339,6 +347,13 @@ protected function _afterIdentifyUser($user, $socialLogin = false, $googleAuthen
// storing user's session in the temporary one
// until the GA verification is checked
$this->request->getSession()->write('temporarySession', $user);

// store the remember me value from login into session temporarily
// to pass the value to verify action
if (Configure::read('Users.RememberMe.active')) {
$this->request->getSession()->write('hasRememberMe', $this->request->getData(Configure::read('Users.RememberMe.Cookie.name')));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an unit test for this

}

$url = Configure::read('GoogleAuthenticator.verifyAction');
$url = array_merge($url, [
'?' => $this->request->getQueryParams()
Expand Down