-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.1] Auth::id() don't get $id from Recaller #13769
Conversation
Thanks, but I'm not quite sure what this fixes? |
Does it not break stuff? |
@@ -180,7 +180,7 @@ public function id() | |||
return; | |||
} | |||
|
|||
$id = $this->session->get($this->getName(), $this->getRecallerId()); | |||
$id = $this->session->get($this->getName()); |
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.
$this->getRecallerId()
get user id from cookie,but it did not check whether the cookie's token is valid
Code logic has not changed, just get the vaule from a trusted function |
Signing out in other browsers would have no effect on this browser's cookies. |
https://github.com/laravel/framework/blob/5.1/src/Illuminate/Auth/Guard.php#L550 First of all pls look at the link I post above.
test: browser A,session expired and remember cookie exist. // browser A,session expired and remember cookie exist.
Auth::id(); // return 1
Auth::user(); // return user object by 1 If you firstly logout on browser B, then try to run the code on browser A in the same situation, it would not get the same result . // browser B logout
// browser A,session expired and remember cookie exist.
Auth::id(); // return 1
Auth::user(); // return null This is what I fixed: // browser B logout
// browser A,session expired and remember cookie exist.
Auth::id(); // return null
Auth::user(); // return null |
OK will take a look. |
The
id
function note: Get the ID for the currently authenticated user.if get id from
remember
cookie, the cookie may invalid.(If a user sign out in other browsers)