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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners