Manual Authentication (Login, Registration)
Scaffolded authentication is convenient, but understanding the manual process behind it makes it far easier to customize login and registration flows for specific application needs.
Manual Registration
Registering a user manually involves validating the submitted data, hashing the password (never storing it in plain text), creating the user record, and typically logging the user in immediately afterward.
Manual Login
Logging a user in manually involves validating their credentials against the stored, hashed password, and asking Laravel's authentication system to start a session for them if the credentials match.
| Method | Purpose |
|---|---|
Hash::make($password) | Securely hashes a plain-text password before storing it |
Auth::attempt($credentials) | Verifies credentials and logs the user in if valid |
Auth::login($user) | Logs in a specific, already-verified user instance |
Auth::logout() | Ends the current user's authenticated session |
Auth::check() | Checks whether a user is currently authenticated |
Good Practices
- Never store or compare plain-text passwords directly
- Regenerate the session after login to prevent session fixation attacks
- Rate-limit login attempts to reduce the risk of brute-force attacks
Once a user is authenticated, the next question is usually what they're allowed to do — which is where role-based access control comes in.
Ready to master Laravel Training Course?
Join Uncodemy's hands-on Laravel program and build real, production-ready applications.
