PHP code example of 1abdulaziz / laravel-quick-login

1. Go to this page and download the library: Download 1abdulaziz/laravel-quick-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/ */

    

1abdulaziz / laravel-quick-login example snippets


use Illuminate\Http\Request;
use LaravelQuickLogin\OneTimeLoginService;

Route::get('/login/token/{token}', function (Request $request, string $token, OneTimeLoginService $service) {
    $user = $service->loginWithToken($token);

    return $user
        ? redirect('/')->with('status', 'Logged in successfully.')
        : redirect('/login')->withErrors(['token' => 'Invalid or expired token.']);
})->name('login.via.token');

use LaravelQuickLogin\OneTimeLoginService;

$service = app(OneTimeLoginService::class);
$url = $service->generateLoginUrl($userId); // valid for 2 minutes by default

$url = $service->generateLoginUrl($userId, 10); // 10 minutes
bash
php artisan uli 12 --minutes=5