dipeshsrv/auth-components-laravel

Reusable auth components for Laravel 12

v1.0.0 2025-06-15 23:19 UTC

This package is not auto-updated.

Last update: 2025-06-16 00:07:13 UTC


README

A reusable authentication package for Laravel 12+ that includes:

  • ✅ Sign Up (Registration)
  • ✅ Sign In (Login)
  • ✅ Forgot Password
  • ✅ Reset Password (with hashed email check)
  • ✅ Dashboard (Authenticated Route)

This package helps you quickly implement common authentication functionality into your Laravel app.

🚀 Installation

Step 1: Require the package

composer require dipeshsrv/auth-components-laravel  

🛠️ Setup Instructions

Step 2: Run Migrations

Publish the migration and run it:

php artisan vendor:publish --tag=authcomponents-migrations
php artisan migrate

This creates a users table with name, email, phone, and password.

Step 3: Publish Views (optional)

php artisan vendor:publish --tag=authcomponents-views

This copies the package views to:

resources/views/vendor/authcomponents/

You can customize them as needed.

Step 4: Routes Provided

These routes are automatically loaded via the package:

MethodURINameDescription
GET/loginloginShow login form
POST/loginSubmit login
POST/logoutlogoutLogout user
GET/registerauthcomponents.register.formShow registration form
POST/registerauthcomponents.register.submitSubmit registration
GET/forgot-passwordpassword.requestShow forgot password
POST/forgot-passwordpassword.emailSend reset link email
GET/reset-password/{token}password.resetShow reset form
POST/reset-passwordpassword.updateSubmit new password
GET/dashboarddashboardProtected dashboard view

🔐 Security Enhancement – Hashed Email Verification

As part of the password reset process, this package adds a security enhancement:
It validates the email using a hashed SHA-256 value passed in the reset URL:

Example:

/reset-password/{token}?email=user@example.com&hash=hashed_value

The reset form will compare this hash with the actual email to protect from tampering.

Note: By default, the hash is generated and checked internally in the controller.
You don’t need to implement a custom notification unless you want to generate a custom URL format manually.

✅ Example Usage

Once installed and set up:

  • Visit /register to sign up a new user
  • Log in via /login
  • After login, you will be redirected to /dashboard
  • You can click Logout to end the session
  • Use /forgot-password to trigger password reset flow

📂 Directory Structure (inside the package)

auth-components-laravel/
├── src/
│   ├── Http/
│   │   └── Controllers/
│   ├── Database/
│   │   └── Migrations/
│   ├── resources/
│   │   └── views/
│   └── routes/
│       └── web.php
├── composer.json
├── README.md

🧪 Development Notes

This package is stored on GitLab and intended for internal reuse. If you clone and modify it, don’t forget to:

git tag v1.0.0
git push origin v1.0.0

And in your consuming Laravel project:

composer require dipeshsrv/auth-components-laravel:dev-main

🙋‍♂️ Author

Dipesh Jagtap
@dipeshsrv

📄 License

MIT License