Skip to main content

Auth Livewire Components

This page documents the Livewire components used for authentication in LaraCMS, including login, registration, password reset, and email verification.

Login

Namespace: App\Livewire\Auth\Login Location: app/Livewire/Auth/Login.php:16 Layout: components.layouts.auth Handles user authentication with rate limiting and remember me functionality.

Properties

PropertyTypeValidationDefaultDescription
$emailstringrequired|string|email''User’s email address
$passwordstringrequired|string''User’s password
$rememberbool-falseRemember me checkbox state

Public Methods

login()

Authenticates the user with rate limiting.
public function login(): void
Behavior:
  • Validates input fields
  • Checks rate limiting (max 5 attempts)
  • Attempts authentication
  • Regenerates session on success
  • Redirects to intended page or home
Rate Limiting:
  • Maximum 5 login attempts
  • Uses email + IP address as throttle key
  • Fires Lockout event when limit exceeded
  • Returns time until retry is available
Exceptions:
  • Throws ValidationException on failed login
  • Throws ValidationException on rate limit exceeded

Protected Methods

ensureIsNotRateLimited()

Checks if the login request is rate limited.
protected function ensureIsNotRateLimited(): void

throttleKey()

Generates the rate limiting key.
protected function throttleKey(): string
Returns: Transliterated lowercase email + IP address

Usage in Blade

<livewire:auth.login />
Example Form:
<form wire:submit="login">
    <input type="email" wire:model="email" placeholder="Email">
    @error('email') <span>{{ $message }}</span> @enderror
    
    <input type="password" wire:model="password" placeholder="Password">
    @error('password') <span>{{ $message }}</span> @enderror
    
    <label>
        <input type="checkbox" wire:model="remember">
        Remember me
    </label>
    
    <button type="submit">Log in</button>
</form>

Register

Namespace: App\Livewire\Auth\Register Location: app/Livewire/Auth/Register.php:16 Layout: components.layouts.auth Handles user registration with Cloudflare Turnstile protection.

Properties

PropertyTypeDefaultDescription
$namestring''User’s full name
$emailstring''User’s email address
$passwordstring''User’s password
$password_confirmationstring''Password confirmation
$turnstilestring''Cloudflare Turnstile token

Public Methods

register()

Registers a new user account.
public function register(): void
Validation Rules:
[
    'name' => ['required', 'string', 'max:255'],
    'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:users'],
    'password' => ['required', 'string', 'confirmed', Password::defaults()],
    'turnstile' => ['required', new Turnstile],
]
Behavior:
  • Validates all input including Turnstile
  • Hashes password
  • Creates user record
  • Fires Registered event
  • Assigns ‘user’ role automatically
  • Logs in the new user
  • Redirects to home page

Usage in Blade

<livewire:auth.register />
Example Form:
<form wire:submit="register">
    <input type="text" wire:model="name" placeholder="Name">
    @error('name') <span>{{ $message }}</span> @enderror
    
    <input type="email" wire:model="email" placeholder="Email">
    @error('email') <span>{{ $message }}</span> @enderror
    
    <input type="password" wire:model="password" placeholder="Password">
    @error('password') <span>{{ $message }}</span> @enderror
    
    <input type="password" wire:model="password_confirmation" placeholder="Confirm Password">
    
    <x-turnstile wire:model="turnstile" />
    @error('turnstile') <span>{{ $message }}</span> @enderror
    
    <button type="submit">Register</button>
</form>

ForgotPassword

Namespace: App\Livewire\Auth\ForgotPassword Location: app/Livewire/Auth/ForgotPassword.php:10 Layout: components.layouts.auth Sends password reset links to users.

Properties

PropertyTypeDefaultDescription
$emailstring''User’s email address

Public Methods

Sends a password reset link to the provided email.
public function sendPasswordResetLink(): void
Validation:
  • Email must be required, string, and valid email format
Behavior:
  • Validates email
  • Sends reset link via Laravel’s Password facade
  • Flashes generic success message (security: doesn’t reveal if email exists)

Usage in Blade

<livewire:auth.forgot-password />
Example Form:
<form wire:submit="sendPasswordResetLink">
    <input type="email" wire:model="email" placeholder="Email">
    @error('email') <span>{{ $message }}</span> @enderror
    
    <button type="submit">Send Reset Link</button>
</form>

@if (session('status'))
    <div>{{ session('status') }}</div>
@endif

ResetPassword

Namespace: App\Livewire\Auth\ResetPassword Location: app/Livewire/Auth/ResetPassword.php:16 Layout: components.layouts.auth Resets user password using a token from the reset email.

Properties

PropertyTypeLockedDefaultDescription
$tokenstringYes''Password reset token
$emailstringNo''User’s email address
$passwordstringNo''New password
$password_confirmationstringNo''Password confirmation

Public Methods

mount(string $token)

Initializes the component with the reset token.
public function mount(string $token): void
Parameters:
  • $token (string) - The password reset token from the email link
Behavior:
  • Sets the locked token property
  • Pre-fills email from query string

resetPassword()

Resets the user’s password.
public function resetPassword(): void
Validation Rules:
[
    'token' => ['required'],
    'email' => ['required', 'string', 'email'],
    'password' => ['required', 'string', 'confirmed', Password::defaults()],
]
Behavior:
  • Validates all fields
  • Attempts password reset via Password facade
  • Updates password and remember token
  • Fires PasswordReset event
  • Redirects to login on success
  • Shows error if token is invalid

Usage in Blade

<livewire:auth.reset-password :token="$token" />
Example Form:
<form wire:submit="resetPassword">
    <input type="email" wire:model="email" placeholder="Email">
    @error('email') <span>{{ $message }}</span> @enderror
    
    <input type="password" wire:model="password" placeholder="New Password">
    @error('password') <span>{{ $message }}</span> @enderror
    
    <input type="password" wire:model="password_confirmation" placeholder="Confirm Password">
    
    <button type="submit">Reset Password</button>
</form>

VerifyEmail

Namespace: App\Livewire\Auth\VerifyEmail Location: app/Livewire/Auth/VerifyEmail.php:12 Layout: components.layouts.auth Sends email verification notifications and allows logout.

Public Methods

sendVerification()

Sends an email verification notification.
public function sendVerification(): void
Behavior:
  • Checks if email is already verified
  • Redirects to profile if verified
  • Sends verification notification
  • Flashes ‘verification-link-sent’ status

logout(Logout $logout)

Logs out the current user.
public function logout(Logout $logout): void
Parameters:
  • $logout (Logout) - Logout action dependency injection
Behavior:
  • Executes logout action
  • Redirects to home page

Usage in Blade

<livewire:auth.verify-email />
Example Usage:
<div>
    <p>Please verify your email address.</p>
    
    <button wire:click="sendVerification">Resend Verification Email</button>
    
    @if (session('status') === 'verification-link-sent')
        <p>A new verification link has been sent!</p>
    @endif
    
    <button wire:click="logout">Log Out</button>
</div>

ConfirmPassword

Namespace: App\Livewire\Auth\ConfirmPassword Location: app/Livewire/Auth/ConfirmPassword.php:11 Layout: components.layouts.auth Confirms the current user’s password for sensitive operations.

Properties

PropertyTypeDefaultDescription
$passwordstring''User’s password

Public Methods

confirmPassword()

Confirms the current user’s password.
public function confirmPassword(): void
Validation:
  • Password must be required and string
Behavior:
  • Validates password against current user
  • Throws ValidationException if password is incorrect
  • Stores confirmation timestamp in session
  • Redirects to intended page or home

Usage in Blade

<livewire:auth.confirm-password />
Example Form:
<form wire:submit="confirmPassword">
    <p>This is a secure area. Please confirm your password.</p>
    
    <input type="password" wire:model="password" placeholder="Password">
    @error('password') <span>{{ $message }}</span> @enderror
    
    <button type="submit">Confirm</button>
</form>

Build docs developers (and LLMs) love