@@ -156,7 +156,7 @@ public function checkAction(string $type, string $token): bool
156156 }
157157
158158 // On success - remove the identity and clean up session
159- $ this ->userIdentityModel ->deleteIdentitiesByType ($ user-> getAuthId () , $ type );
159+ $ this ->userIdentityModel ->deleteIdentitiesByType ($ user , $ type );
160160
161161 // Clean up our session
162162 session ()->remove ('auth_action ' );
@@ -287,7 +287,7 @@ private function checkUserState(): void
287287 $ this ->user = $ this ->provider ->findById ($ userId );
288288
289289 $ identities = $ this ->userIdentityModel ->getIdentitiesByTypes (
290- $ this ->user -> getAuthId () ,
290+ $ this ->user ,
291291 $ this ->getActionTypes ()
292292 );
293293
@@ -474,7 +474,7 @@ public function login(User $user): void
474474 private function issueRememberMeToken ()
475475 {
476476 if ($ this ->shouldRemember && setting ('Auth.sessionConfig ' )['allowRemembering ' ]) {
477- $ this ->rememberUser ($ this ->user -> getAuthId () );
477+ $ this ->rememberUser ($ this ->user );
478478
479479 // Reset so it doesn't mess up future calls.
480480 $ this ->shouldRemember = false ;
@@ -533,7 +533,7 @@ public function logout(): bool
533533 session ()->regenerate (true );
534534
535535 // Take care of any remember-me functionality
536- $ this ->rememberModel ->purgeRememberTokens ($ this ->user -> getAuthId () );
536+ $ this ->rememberModel ->purgeRememberTokens ($ this ->user );
537537
538538 // Trigger logout event
539539 $ result = Events::trigger ('logout ' , $ this ->user );
@@ -545,20 +545,15 @@ public function logout(): bool
545545
546546 /**
547547 * Removes any remember-me tokens, if applicable.
548- *
549- * @param int|string|null $userId ID of user to forget.
550548 */
551- public function forget ($ userId = null ): void
549+ public function forget (? User $ user = null ): void
552550 {
553- if (empty ($ userId )) {
554- if (! $ this ->loggedIn ()) {
555- return ;
556- }
557-
558- $ userId = $ this ->user ->getAuthId ();
551+ $ user ??= $ this ->user ;
552+ if ($ user === null ) {
553+ return ;
559554 }
560555
561- $ this ->rememberModel ->purgeRememberTokens ($ userId );
556+ $ this ->rememberModel ->purgeRememberTokens ($ user );
562557 }
563558
564559 /**
@@ -611,11 +606,9 @@ public function recordActiveDate(): void
611606 *
612607 * @see https://paragonie.com/blog/2015/04/secure-authentication-php-with-long-term-persistence
613608 *
614- * @param int|string $userId
615- *
616609 * @throws Exception
617610 */
618- protected function rememberUser ($ userId ): void
611+ protected function rememberUser (User $ user ): void
619612 {
620613 $ selector = bin2hex (random_bytes (12 ));
621614 $ validator = bin2hex (random_bytes (20 ));
@@ -625,7 +618,7 @@ protected function rememberUser($userId): void
625618
626619 // Store it in the database.
627620 $ this ->rememberModel ->rememberUser (
628- $ userId ,
621+ $ user ,
629622 $ selector ,
630623 $ this ->hashValidator ($ validator ),
631624 $ expires
0 commit comments