Configuration
Enable OTP codes and runphp artisan admin:migrate. It creates the tables of the OTP codes and the whitelisted accounts.
config/admin_helpers.php
'chars' => 0, 'numbers' => 5 for a numeric code. Codes are not case sensitive.
Channels
Theverificator request parameter selects where the code is sent:
The default is the
AUTH_VERIFICATOR environment variable, or email. When a user without a phone asks for an SMS code, the code is sent by e-mail.
OTP response
Routes which send a code return its details in theotp store:
formatdescribes the code:xis a letter,0a number. Use it for the input mask of the app.identifieris masked, e.g.j***@e***m, when the code was resent to another channel of a signed in user.tokencontains the code only for test identifiers.verified: truemeans no code was sent, because the e-mail or phone is already verified.
Routes
AdminAuth::otp() registers:
Send another
verificator to auth/otp/resend to switch the channel, e.g. from e-mail to SMS. For a registered user, the code goes to the e-mail or phone stored in the database, not to the request value.
SMS codes
Codes for phone numbers are sent through SmartSMS byAdminHelpers\Sms\SmartSms. Set the credentials in .env:
.env
SMARTSMS_PASSWORD_MD5can hold the MD5 hash of the password instead ofSMARTSMS_PASSWORD.- With
SMARTSMS_TEST=true, the default, messages are only written to the log: thesmslog channel when it exists, otherwisesingle. - A
config/smartsms.phpfile with the keysusername,password,from,testandlog_channelreplaces the values from.env.
sms notification channel. It sends the toSms($notifiable) text of a notification to routeNotificationForSms() of the notifiable, or to its phone attribute. The SMS login verification of the administration uses this channel.
app/Notifications/OrderShipped.php
Testing
Test identifiers receive no e-mail or SMS. The response returns the code inotp.token instead.
config/admin_helpers.php
whitelisted_tokens, so testers can use a fixed code:
config/admin_helpers.php
Debug mode
WithAUTH_TOKEN_DEBUG=true, every e-mail and phone is a test identifier. Debug mode works only when APP_DEBUG is enabled and the environment is local or stagging.
.env
Whitelisted accounts
The Allowed OTP e-mails module in the Settings group of the administration turns real codes off for an e-mail or phone for 15 minutes. Use it for app store reviewers or for support. During that time, the account accepts the codes ofwhitelisted_tokens.
Custom OTP model
Extend the OTP model to change how codes are generated or sent. Keep its table:app/Models/Auth/OtpToken.php
php artisan otp:clean. The command is not scheduled automatically.
