Skip to content

Commit

Permalink
Extending Authentication UserProviderInterace 4.1.26 update
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbabic committed Jul 9, 2014
1 parent 6d231d9 commit 7ab844b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,19 @@ Let's take a look at the `UserProviderInterface`:
interface UserProviderInterface {

public function retrieveById($identifier);
public function retrieveByToken($identifier, $token);
public function updateRememberToken(UserInterface $user, $token);
public function retrieveByCredentials(array $credentials);
public function validateCredentials(UserInterface $user, array $credentials);

}

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.

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.

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.

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.**

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']`.
Expand Down

0 comments on commit 7ab844b

Please sign in to comment.