PHP code example of grazulex / laravel-oneclicklogin
1. Go to this page and download the library: Download grazulex/laravel-oneclicklogin 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/ */
grazulex / laravel-oneclicklogin example snippets
use Grazulex\OneClickLogin\Facades\OneClickLogin;
// Send a magic link with expiration
$link = OneClickLogin::to($user)
->via('mail')
->expireIn(15) // 15 minutes
->withContext(['redirect' => '/dashboard'])
->send();
echo $link->getSignedUrl(); // https://yourapp.com/login/magic?token=abc123xyz
// Magic link with persona context
OneClickLogin::to($user)
->via('mail')
->expireIn(30)
->withContext([
'persona' => 'client',
'tenant' => 123,
'role' => 'admin',
'redirect'=> '/admin/dashboard',
'remember'=> true
])
->bindIp() // Optional IP binding
->bindDevice($request) // Optional device binding
->send();
// Secure magic link with IP restrictions and OTP step-up
OneClickLogin::to($user)
->via('mail')
->expireIn(15)
->bindIp() // Bind to current IP
->bindDevice($request) // Bind to device fingerprint
->withContext([
'redirect' => '/secure-area',
'otp_