1. Go to this page and download the library: Download empuxa/laravel-totp-login library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
empuxa / laravel-totp-login example snippets
'route' => [
'prefix' => 'auth', // Changes routes to /auth, /auth/code, etc.
'middleware' => ['web', 'guest'],
],
use Empuxa\TotpLogin\Controllers\HandleCodeRequest;
use Empuxa\TotpLogin\Controllers\HandleIdentifierRequest;
use Empuxa\TotpLogin\Controllers\ShowCodeForm;
use Empuxa\TotpLogin\Controllers\ShowIdentifierForm;
Route::prefix('auth')->group(static function (): void {
Route::get('/login', ShowIdentifierForm::class)->name('totp-login.identifier.form');
Route::post('/login', HandleIdentifierRequest::class)->name('totp-login.identifier.handle');
Route::get('/login/code', ShowCodeForm::class)->name('totp-login.code.form');
Route::post('/login/code', HandleCodeRequest::class)->name('totp-login.code.handle');
});
// config/totp-login.php
'columns' => [
'identifier' => 'phone', // Use phone number instead of email
],
'identifier' => [
'validation' => '
public static function totpLoginScope(): Builder
{
return self::where('email_verified_at', '!=', null)
->where('status', 'active');
}
public static function totpLoginScope(): Builder
{
return self::withoutTrashed();
}
public static function totpLoginScope(): Builder
{
return self::where('tenant_id', session('tenant_id'));
}