--- title: Authenticators --- ### Authenticators Authenticators are responsible for authenticating credentials and login attempts. #### Authenticator Extension This section will go over the `\Anomaly\UsersModule\User\Authenticator\AuthenticatorExtension` class. ##### AuthenticatorExtension::authenticate() The `authenticate` method is responsible for authenticating the `credentials` and returning `null`, a `user`, or a `redirect`. ###### Returns: `\Anomaly\UsersModule\User\Contract\UserInterface` or `\Illuminate\Http\RedirectResponse` or `null` ###### Arguments
Key Required Type Default Description
$credentials true array none The login information.
#### Writing Authenticators This section will show you how to write your own custom authenticator extension. ##### Creating the extension The first thing we need to do is to use the `make:addon` command to create our extension: php artisan make:addon anomaly.extension.default_authenticator ##### Extending the authenticator extension The extension you create must extend the `\Anomaly\UsersModule\User\Authenticator\AuthenticatorExtension` class: credentials = $credentials; } /** * Handle the command. * * @param UserRepositoryInterface $users * @return \Anomaly\UsersModule\User\Contract\UserInterface|null */ public function handle(UserRepositoryInterface $users) { if (!isset($this->credentials['password']) && !isset($this->credentials['email'])) { return null; } return $users->findByCredentials($this->credentials); } } ##### Redirecting authentication requests The `authenticate` method can return an instance of the user, null, or a redirect instance. In the case a redirect is returns the request will be redirected immediately. After the redirect is made the authentication will be in your hands!