Password-less Login with Magic Link in Laravel 8
Provide users with a secure URL that automatically logs them in
Send the user an email containing a secure url
use Illuminate\Support\Facades\URL;
//
public function toMail($notifiable)
{
return (new MailMessage)
->line('Here is your login PassPhrase which is valid for the next 15 minutes')
->line($this->passphrase)
->line('Or click the button to access the site (opens in a new window)')
->action('Confirm', URL::temporarySignedRoute(
'login.magiclink',
now()->addMinutes(15),
['user' => $notifiable->id, 'code' => $this->passphrase]
))
->line('Thank you for using our application!');
}Create a controller for the secure endpoint
Add the route
Testing
Feedback
Last updated