AdminAuth::login() registers four routes:
Finding the user
The user is found by the first of these parameters:identifier, compared with every login column of the model, i.e.emailandphoneemailphone, formatted to E.164
getRequestCasts() in your controller:
app/Http/Controllers/Auth/LoginController.php
findUser() when users are stored in several models, or when some of them must not sign in:
app/Http/Controllers/Auth/LoginController.php
Password login
POST /api/auth/login
401.
OTP login
POST auth/login/otpsends a code to the e-mail or phone of the user.verificatorselects the channel,emailorphone. It defaults toAUTH_VERIFICATOR.POST auth/login/otp-verifywithtokensigns the user in, and marks the e-mail or phone as verified.
Social login
POST auth/login/socialite/{driver} signs in with an access token or ID token from a mobile or web SDK of the provider. The user is found or registered by the crudadmin/socialite package, and its e-mail is marked as verified.
POST /api/auth/login/socialite/google
Login response
driveris the table of the user model.useris the result ofsetAuthResponse()of the model.device_tokenslists the push notification tokens of the user when notifications are enabled.tokenis a new Sanctum token. Send it asAuthorization: Bearer {token}.
Bootstrap response
Withadmin_helpers.auth.response = 'bootstrap', login, registration and password reset return the authenticated() sections of the bootstrap request selected by the app-type header, plus the auth section with the new token. Projects get the data of the signed in user in one response, e.g. the merged cart of an e-shop.
store when autoajax.store is enabled, otherwise merged into data. The bootstrap class must extend AdminHelpers\Utilities\BootstrapRequest.
Login controller
Extend the default controller to change the guard or the response.app/Http/Controllers/Auth/LoginController.php
Custom response
OverrideauthorizedResponse(). Share it with the registration controller through a trait, so both return the same data. This example returns the bootstrap request of the signed in user:
app/Utilities/Traits/HasAuthResponse.php
$type is the name of the new token: login, register or social. It is null for the user route, which creates no token.
Token abilities
Tokens have the* ability by default. Override tokenAbilities() to limit them:
app/Http/Controllers/Auth/LoginController.php
Signed in user
GET user returns the same response as the login, without a new token. Register it in a group with your auth middleware.
Logout
auth/logout deletes the current token, and the push notification tokens of the device which used it.