final class ModelUserProvider implements UserProvider

Retrieves and validates Principals backed by the Users model. Isolates all knowledge of how users are stored and looked up, so the guard can authenticate against the Users model through the UserProvider contract without depending on it directly.

Properties

private Hasher $hasher

The hasher used to verify supplied passwords against stored hashes.

Methods

__construct(Hasher $hasher)

No description

Principal|null
retrieveById(mixed $id)

Retrieves a principal by its unique identifier.

Principal|null
retrieveByCredentials(array $credentials)

Retrieves a principal matching the given credentials, without verifying them. Looks the user up by username only; password verification is performed separately by validateCredentials().

bool
validateCredentials(Principal $user, array $credentials)

Verifies that the supplied password matches the principal's stored hash.

Details

at line 27
__construct(Hasher $hasher)

No description

Parameters

Hasher $hasher

The hasher used to verify credentials.

at line 37
Principal|null retrieveById(mixed $id)

Retrieves a principal by its unique identifier.

Parameters

mixed $id

The identifier of the principal to retrieve.

Return Value

Principal|null

The matching principal, or null if none exists for the given identifier.

at line 51
Principal|null retrieveByCredentials(array $credentials)

Retrieves a principal matching the given credentials, without verifying them. Looks the user up by username only; password verification is performed separately by validateCredentials().

Parameters

array $credentials

The credentials used to locate the principal (e.g. ['username' => ...]).

Return Value

Principal|null

The matching principal, or null if none is found.

at line 66
bool validateCredentials(Principal $user, array $credentials)

Verifies that the supplied password matches the principal's stored hash.

Parameters

Principal $user

The principal whose credentials are being verified.

array $credentials

The credentials to verify (e.g. ['password' => ...]).

Return Value

bool

True if the credentials are valid for the principal, otherwise false.