Skip to content

Latest commit

Β 

History

History
606 lines (457 loc) Β· 19.8 KB

File metadata and controls

606 lines (457 loc) Β· 19.8 KB

πŸ” Public Authentication & User Management

Complete guide for the public authentication system, user roles, and user management in the admin panel.

Table of Contents


Overview

The application features a complete public authentication system that is separate from the Filament admin panel:

  • πŸ‘₯ Public Users - Can login and manage their own profiles
  • πŸ‘¨β€πŸ’Ό Admin Users - Have access to admin panel plus all public features
  • πŸ” Password Security - All passwords hashed with bcrypt
  • 🌐 Multilingual - Login and profile pages available in FR, EN, DE
  • πŸŒ™ Dark Mode - Full dark mode support on all authentication pages

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       Authentication System v2.0        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                         β”‚
β”‚  Public Routes (No Auth Required)       β”‚
β”‚  β”œβ”€β”€ GET  /login          Login page    β”‚
β”‚  └── POST /login          Authenticate  β”‚
β”‚                                         β”‚
β”‚  Protected Routes (Login Required)      β”‚
β”‚  β”œβ”€β”€ GET  /profile        Profile page  β”‚
β”‚  β”œβ”€β”€ POST /profile        Edit profile  β”‚
β”‚  └── POST /logout         Logout        β”‚
β”‚                                         β”‚
β”‚  Admin Routes (Admin Only)              β”‚
β”‚  └── /admin/resources/users  User CRUD  β”‚
β”‚                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

User Roles

Public User

A user account without admin privileges.

Permissions:

  • βœ… Login to public login page (/login)
  • βœ… Access profile page (/profile)
  • βœ… Edit own name and email
  • βœ… Change own password
  • ❌ Cannot access admin panel (/admin)

Database Field: is_admin = false

Admin User

A user account with full admin privileges.

Permissions:

  • βœ… Login to public login page (/login)
  • βœ… Automatically redirected to admin panel (/admin)
  • βœ… Full access to admin panel (all resources, settings)
  • βœ… Manage all users (create, edit, delete)
  • βœ… View all API clients, keys, logs
  • βœ… Configure application settings

Database Field: is_admin = true


Public Login

Login Page

URL: GET /login

The login page provides a simple, secure form for users to authenticate.

Features

  • πŸ“± Responsive Design - Works on mobile and desktop
  • πŸŒ™ Dark Mode - Respects browser and user theme preference
  • 🌍 Multilingual - Available in FR, EN, DE
  • ⚠️ Error Messages - Clear feedback on failed attempts
  • βœ… Form Validation - Client-side and server-side validation

Form Fields

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Login to API Manager        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                     β”‚
β”‚ Email Address:                      β”‚
β”‚ [_____________________________]     β”‚
β”‚                                     β”‚
β”‚ Password:                           β”‚
β”‚ [_____________________________]     β”‚
β”‚                                     β”‚
β”‚ [ ] Remember me                     β”‚
β”‚                                     β”‚
β”‚          [Login Button]             β”‚
β”‚                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Authentication Process

Step 1: User submits form

POST /login
Content-Type: application/x-www-form-urlencoded

email=user@example.com&password=secret123

Step 2: Application validates

  • Email exists in database
  • Password matches hash
  • Account is not deleted

Step 3: Success β†’ Role-based redirect

If is_admin = true:
  β†’ Redirect to GET /admin
  
If is_admin = false:
  β†’ Redirect to GET /profile

Step 4: Error β†’ Show form with message

Invalid email or password. Please try again.

Form Validation

Client-Side (Browser):

  • Email: Required, must be valid email format
  • Password: Required, minimum 8 characters

Server-Side (Laravel):

  • Email: Required, email format, must exist in users table
  • Password: Required, must match bcrypt hash

Session Management

After successful login:

  • User session created with encrypted cookie
  • auth()->user() available in controllers/views
  • Session expires after 2 hours of inactivity (configurable)
  • Session can be cleared by logout

Failed Login Attempts

Currently, the application:

  • Shows generic error message
  • Does not lock accounts after multiple failures
  • Logs failed attempts in application logs

Note: For production, consider adding:

  • Rate limiting per IP (e.g., 5 attempts per 15 minutes)
  • Account lockout after N failed attempts
  • Email notification on suspicious activity

Profile Management

Profile Page

URL: GET /profile (requires login)

Protected page where logged-in users can view and edit their profile.

Features

  • πŸ“ Edit Name & Email - Update personal information
  • πŸ”‘ Change Password - Secure password update
  • πŸ“§ Email Verification - Optional email verification on change
  • βœ… Form Validation - All fields validated
  • πŸ’Ύ Persistent - All changes saved immediately
  • πŸ“± Responsive - Works on all devices
  • πŸŒ™ Dark Mode - Full dark mode support

Edit Profile Section

Allows users to update their basic information:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚            Edit Profile                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                         β”‚
β”‚ Full Name:                              β”‚
β”‚ [John Doe_____________________]         β”‚
β”‚                                         β”‚
β”‚ Email Address:                          β”‚
β”‚ [john@example.com____________]         β”‚
β”‚                                         β”‚
β”‚           [Save Changes]                β”‚
β”‚                                         β”‚
β”‚ βœ… Changes saved successfully!          β”‚
β”‚                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Fields:

  • name (Required, minimum 2 characters)
  • email (Required, valid email format, must be unique)

Validation:

  • Name: required|string|min:2|max:255
  • Email: required|email|unique:users,email,{id}|max:255

Success: Form clears, success message shown, database updated

Error: Field errors displayed inline, existing data retained

Change Password Section

Allows users to securely update their password:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Change Password                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                         β”‚
β”‚ Current Password:                       β”‚
β”‚ [________________________]              β”‚
β”‚                                         β”‚
β”‚ New Password:                           β”‚
β”‚ [________________________]              β”‚
β”‚                                         β”‚
β”‚ Confirm Password:                       β”‚
β”‚ [________________________]              β”‚
β”‚                                         β”‚
β”‚           [Update Password]             β”‚
β”‚                                         β”‚
β”‚ βœ… Password updated successfully!       β”‚
β”‚                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Fields:

  • current_password (Required, must match user's password)
  • new_password (Required, minimum 8 characters, different from current)
  • password_confirmation (Required, must match new_password)

Validation:

  • Current password: required|current_password
  • New password: required|string|min:8|confirmed|different:current_password

Security:

  • Current password verified before allowing change
  • New password hashed with bcrypt before storage
  • Old password immediately invalidated
  • User not logged out (session continues)

Success: Password hash updated in database, success message shown

Error: Validation errors displayed inline, password not changed


Admin User Management

User Resource

URL: /admin/resources/users

Only accessible to admin users. Provides full CRUD operations for all users.

Features:

  • βœ… Create Users - Add new user accounts
  • βœ… Read Users - List all users with search/filter
  • βœ… Update Users - Edit user details and password
  • βœ… Delete Users - Remove user accounts
  • βœ… Search - Find users by name or email
  • βœ… Pagination - View 10 users per page
  • 🌐 Multilingual - Resource labels in FR, EN, DE
  • πŸŒ™ Dark Mode - Full Filament dark mode support

Create User

Action: Click "Create" button in user list

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          Create New User               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                        β”‚
β”‚ Name:                                  β”‚
β”‚ [_____________________________]        β”‚
β”‚                                        β”‚
β”‚ Email:                                 β”‚
β”‚ [_____________________________]        β”‚
β”‚                                        β”‚
β”‚ Password:                              β”‚
β”‚ [_____________________________]        β”‚
β”‚                                        β”‚
β”‚ Admin:                                 β”‚
β”‚ [No β–Ό] ← Toggle to make admin          β”‚
β”‚                                        β”‚
β”‚ [Cancel]                [Create]       β”‚
β”‚                                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Required Fields:

  • name - Full name (required, 2-255 characters)
  • email - Email address (required, valid email, unique)
  • password - Initial password (required, min 8 chars, auto-hashed)
  • is_admin - Admin role toggle (optional, default false)

After Creation:

  • User receives initial password (communicate securely to user)
  • User can login with email and password
  • User can change password on first login
  • Admin user gets /admin access

Read/List Users

Action: Navigate to /admin/resources/users

Shows a table of all users with:

  • Name
  • Email
  • Admin status (badge)
  • Created date
  • Last updated date
  • Action buttons (Edit, Delete)

Search: Enter name or email to filter users

Pagination: 10 users per page, navigate with arrows

Edit User

Action: Click "Edit" button next to user

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          Edit User (John Doe)          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                        β”‚
β”‚ Name:                                  β”‚
β”‚ [John Doe_____________________]        β”‚
β”‚                                        β”‚
β”‚ Email:                                 β”‚
β”‚ [john@example.com____________]        β”‚
β”‚                                        β”‚
β”‚ Change Password:                       β”‚
β”‚ [_____ New password (optional)____]   β”‚
β”‚ [Password is only updated if filled]   β”‚
β”‚                                        β”‚
β”‚ Admin:                                 β”‚
β”‚ [Yes β–Ό] ← Toggle to change role        β”‚
β”‚                                        β”‚
β”‚ Created: Jan 15, 2026 at 10:30 AM      β”‚
β”‚ Updated: Mar 20, 2026 at 02:15 PM      β”‚
β”‚                                        β”‚
β”‚ [Cancel]                [Update]       β”‚
β”‚                                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Editable Fields:

  • name - Full name (required, 2-255 characters)
  • email - Email address (required, valid email, unique except self)
  • password - Change password (optional, only if filled, min 8 chars)
  • is_admin - Admin role toggle

Important:

  • Password field is optional
  • If left empty, password is NOT changed
  • If filled, it MUST be at least 8 characters
  • Password is automatically hashed with bcrypt before saving
  • Email uniqueness checked (except for this user's current email)

After Update:

  • User data immediately updated in database
  • Changes take effect on user's next page load
  • User session continues (not forced to logout)

Delete User

Action: Click "Delete" button next to user

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Are you sure you want to delete this? β”‚
β”‚                                        β”‚
β”‚  This action cannot be undone.         β”‚
β”‚                                        β”‚
β”‚  User: john@example.com                β”‚
β”‚                                        β”‚
β”‚  [Cancel]               [Delete]       β”‚
β”‚                                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Warning: Deletion is permanent and cannot be undone

Effects:

  • User account completely removed from database
  • User can no longer login
  • User's API keys become inaccessible (if future feature added)
  • User cannot recover their account

Security

Password Hashing

All passwords are hashed using bcrypt with:

  • Algorithm: bcrypt (PHP's password_hash())
  • Cost: 12 (default)
  • Verification: password_verify() or Laravel's Hash::check()

Never Stored:

  • Plain text passwords
  • Encrypted passwords
  • Passwords in logs
  • Passwords in error messages

Session Security

Laravel sessions are:

  • Encrypted - AES-256-CBC encryption
  • Signed - HMAC-SHA256 signature for tampering detection
  • Secure Cookie - secure flag set (HTTPS only in production)
  • HttpOnly - Prevents JavaScript access to session cookie
  • SameSite=strict - Prevents CSRF attacks

Session Expiration:

  • Default: 2 hours of inactivity
  • Configurable in config/session.php

CSRF Protection

Every POST request (login, profile update) includes:

  • @csrf token in form (Blade)
  • Token verified by middleware before processing
  • Prevents cross-site request forgery attacks

Rate Limiting (Optional)

Consider adding in production:

Route::post('/login', [LoginController::class, 'store'])
    ->middleware('throttle:5,15');  // 5 attempts per 15 minutes per IP

Multilingual Support

All authentication pages are fully internationalized in French, English, and German.

Translation Keys

Login Page (auth.login.*):

auth.login.title              β†’ Page title
auth.login.email              β†’ Email label
auth.login.password           β†’ Password label
auth.login.remember           β†’ Remember me checkbox
auth.login.button             β†’ Submit button text
auth.login.no_account         β†’ Sign up link text

Profile Page (auth.profile.*):

auth.profile.title                  β†’ Page title
auth.profile.edit_profile           β†’ Section heading
auth.profile.name                   β†’ Name field label
auth.profile.email                  β†’ Email field label
auth.profile.change_password        β†’ Section heading
auth.profile.current_password       β†’ Field label
auth.profile.new_password           β†’ Field label
auth.profile.confirm_password       β†’ Field label
auth.profile.save                   β†’ Save button text

Validation Messages (auth.validation.*):

auth.validation.email_required      β†’ Email required error
auth.validation.email_invalid       β†’ Invalid email format error
auth.validation.password_required   β†’ Password required error
auth.validation.password_min        β†’ Password too short error
auth.validation.name_required       β†’ Name required error

Switching Languages

Click the language button (F/EN/DE) in navbar to switch languages immediately.

Language preference is saved in session and persists across pages.


Troubleshooting

Cannot Login

Symptom: "Invalid email or password" message, but credentials seem correct

Solutions:

  1. Verify email is spelled correctly (case-insensitive)
  2. Reset password via admin panel and try new password
  3. Check if account is deleted (verify in /admin/resources/users)
  4. Check application logs: tail -f storage/logs/laravel.log

Password Change Not Working

Symptom: Form submits but password doesn't change

Solutions:

  1. Verify current password field is correct
  2. Verify new password is at least 8 characters
  3. Verify password confirmation matches new password
  4. Check form validation errors displayed inline
  5. Clear browser cache and try again

Cannot Access Admin Panel

Symptom: Redirected back to profile after login

Solutions:

  1. Verify user is_admin is set to true in database:

    php artisan tinker
    >>> User::where('email', 'user@example.com')->first()->is_admin
  2. Set user as admin from existing admin account via /admin/resources/users

  3. Or via tinker:

    >>> $user = User::where('email', 'user@example.com')->first();
    >>> $user->update(['is_admin' => true]);

"Remember Me" Not Working

Symptom: Gets logged out after closing browser despite checking "Remember me"

Note: Current implementation does not use "Remember me" feature. Session ends when browser is closed.

Future: Can be implemented with API tokens or persistent login cookies.

Session Expires Too Quickly

Symptom: Gets logged out after 2 hours of activity

Solution: This is by design for security. Adjust in config/session.php:

'lifetime' => env('SESSION_LIFETIME', 120),  // minutes

Set to higher value (e.g., 1440 for 24 hours) for longer sessions.


API Integration (Future)

The public authentication system can be extended with:

  • API Tokens - Allow users to generate tokens for API access
  • OAuth2 - Social login via Google, GitHub, etc.
  • Two-Factor Authentication - TOTP/SMS based 2FA
  • Email Verification - Require email verification on signup
  • Password Reset - Self-service password recovery
  • User Registration - Allow public signup with admin approval

Admin Panel User Management

See README.md for overview of Filament user management and role-based access.

See MULTILINGUAL.md for i18n keys used in authentication pages.


Last Updated: 2026-04-10 Version: 2.0.0 Status: βœ… Production Ready