Sometimes we don’t want users to have passwords. Sometimes we want to send a magic link to a user’s email address and have them click to gain access.

While we are at it, we can remove the password resets table, as we will not have a password to reset.

final class LoginForm extends Component { public string $email = ''; public string $status = ''; public function submit(SendLoginLink $action): void { $this->validate(); $action->handle( email: $this->email, ); $this->status = 'An email has been sent for you to log in. '; } public function rules(): array { return [ 'email' => [ 'required', 'email', Rule::exists( table: 'users', column: 'email', ), ]]; } public function render(): View { return view('livewire.auth.login-form'); }}

final class SendLoginLink { public function handle(string $email): void { Mail::to( users: $email, )->send( mailable: new LoginLink( url: URL::temporarySignedRoute( name: 'login:store', parameters: [ 'email' => $email, ], expiration: 3600, ), )); }}
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners