Validating a User's Credentials

Problem

You want to validate a user's credentials, but you don't want to log the user in.

Solution

Use the Auth::validate() method.

The method takes an array containing the user's credentials.

$credentials = [
    'username' => 'mylogin',
    'password' => 'mypass',
];
$valid = Auth::validate($credentials);
if ( ! $valid)
{
    throw new Exception('Invalid credentials');
}

Discussion

The validation will fire an auth.attempt event with the credentials.

comments powered by Disqus