Laravel multiple Admin and User roles authentication using Laravel Breeze Where User and Admin roles on registeration sent OTP to their email address. Resend OTP functionality implement after timer expired.
- PHP Version => 7.4 or higher
- Laravel Version => 8 or higher
- MySQL Version => 5.7 or higher
- git clone repository_url
- cd laravel-breeze-web-guard-user-email-otp
- composer update
- create database and configure .env database connection
- php artisan migrate
- php artisan db:seed
- php artisan serve
- Auth Routes
- User Login : http://127.0.0.1:8000/login
- User Register : http://127.0.0.1:8000/register
- Admin Login : http://127.0.0.1:8000/admin/login
- Admin Register : http://127.0.0.1:8000/admin/register
User Role
- Username : [email protected]
- Password : user@123456
Admin Role
- Username : [email protected]
- Password : admin@123456
- Authentication Using Laravel Web Gaurd :
- Admin Role Requirement
- Admin Registration Fields
- Name : [ Validation Rules : Accept only strings and space, Required ]
- Email : [ Validation Rules : Accept only valid email address, Required ]
- Password : [ Validation Rules : Accept only valid password min 8 length with alphanumeric, Required ]
- Confirm Password : [ Validation Rules : should be same as Password field, Required ]
- On Registration button click redirect to Admin dashboard page
- Generate 5 dummy sample for Admin role using Factory and Seeder
- Make Seprate dashboard view ,admin table and Admin model
- Admin Login Fields
- Email : [ Validation Rules : Accept only valid email address, Required ]
- Password : [ Validation Rules : Accept only valid password min 8 length with alphanumeric, Required ]
- On Login button click redirect to Admin dashboard page if credential is validated
- User Role Requirement
- User Registration Fields
- Name : [ Validation Rules : Accept only strings and space, Required ]
- Email : [ Validation Rules : Accept only valid email address, Required ]
- Password : [ Validation Rules : Accept only valid password minimum 8 length with alphanumeric, Required ]
- Confirm Password : [ Validation Rules : should be same as Password field, Required ]
- On Registration button click send email verification 8 digit OTP to registered email address
- Verify OTP Page will be open with Enter OTP
- 1 minutes timer counter will shows to user
- After 1 minutes timer counter will shows Resend OTP button to user and should able to resend 8 digit OTP at registered email
- After 1 minutes timer counter old OTP will be expired and not allow to login with old OTP
- On Verify OTP Check if OTP is valid then redirect to User Home Page
- Generate 5 dummy sample for User role using Factory and Seeder
- Make Seprate dashboard view ,user table and User model
- User Login Fields
- Email : [ Validation Rules : Accept only valid email address, Required ]
- Password : [ Validation Rules : Accept only valid password min 8 length with alphanumeric, Required ]
- On Login button click redirect to User home page if credential is validated
- Use Laravel's migration scripts for database schema and tables related to further all operations
- Use Laravel's factory and seeders for sample dummy data creations where required
- Use Laravel's validation using Request classes where required
- Use Laravel's Eloquent and Relationships in models where required
- Use camel case for function name and variable name. E.g getProductDetails() , $categoryDetails
- Comment on the above function with short details of that function use or purpose of function creation.
- Reuse the common codes using some helper class functions etc
- Remove unnecessary code and debug points that are not needed
- Avoid unnecessary loops if not required
- Avoid unnecessary variable creations
- Use PHP design patterns where required Design Patterns
- Normalize database tables where required Database Normalization
- Optimize database tables
- Avoid MySQL joins queries if not required
- Avoid MySQL sub queries if it does not require
- For more information, please read the document Code Standard