Skip to content

Commit 7ab844b

Browse files
committed
Extending Authentication UserProviderInterace 4.1.26 update
1 parent 6d231d9 commit 7ab844b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

extending.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,19 @@ Let's take a look at the `UserProviderInterface`:
139139
interface UserProviderInterface {
140140

141141
public function retrieveById($identifier);
142+
public function retrieveByToken($identifier, $token);
143+
public function updateRememberToken(UserInterface $user, $token);
142144
public function retrieveByCredentials(array $credentials);
143145
public function validateCredentials(UserInterface $user, array $credentials);
144146

145147
}
146148

147149
The `retrieveById` function typically receives a numeric key representing the user, such as an auto-incrementing ID from a MySQL database. The `UserInterface` implementation matching the ID should be retrieved and returned by the method.
148150

151+
The `retrieveByToken` function retrieves a user by their unique `$identifier` and "remember me" `$token`, stored in a field `remember_token`. As with with previous method, the `UserInterface` implementation should be returned.
152+
153+
The `updateRememberToken` method updates the `$user` field `remember_token` with the new `$token`. The new token can be either a fresh token, assigned on successfull "remember me" login attempt, or a null when user is logged out.
154+
149155
The `retrieveByCredentials` method receives the array of credentials passed to the `Auth::attempt` method when attempting to sign into an application. The method should then "query" the underlying persistent storage for the user matching those credentials. Typically, this method will run a query with a "where" condition on `$credentials['username']`. **This method should not attempt to do any password validation or authentication.**
150156

151157
The `validateCredentials` method should compare the given `$user` with the `$credentials` to authenticate the user. For example, this method might compare the `$user->getAuthPassword()` string to a `Hash::make` of `$credentials['password']`.

0 commit comments

Comments
 (0)