Skip to content

shayan041ir/login-system

Repository files navigation

Login System

A robust and secure login system built with Laravel, providing authentication, authorization, and user management features.

Features

  • User registration with email verification
  • Secure login and logout functionality
  • Password reset via email
  • Session management
  • Remember me functionality
  • Social media login integration (optional)
  • Two-factor authentication (optional)
  • Role-based access control
  • Account settings and profile management

Prerequisites

  • PHP >= 8.1
  • Composer
  • Node.js and npm
  • MySQL, PostgreSQL, or SQLite
  • Apache or Nginx web server

Installation

  1. Clone the repository:
git clone https://github.com/your-username/login-system.git
cd login-system
  1. Install PHP dependencies:
composer install
  1. Install Node.js dependencies:
npm install
  1. Copy the environment file and set the configuration:
cp .env.example .env
  1. Generate application key:
php artisan key:generate
  1. Configure your database settings in the .env file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password
  1. Run database migrations:
php artisan migrate
  1. If you want to seed the database with sample data:
php artisan db:seed
  1. Build the front-end assets:
npm run build

or for development with hot reloading:

npm run dev

Configuration

Environment Variables

  • APP_NAME: The name of your application
  • APP_ENV: The application environment (local, production, etc.)
  • APP_KEY: The application key (auto-generated)
  • DB_*: Database configuration
  • MAIL_*: Mail server configuration for password resets
  • CACHE_*: Cache driver configuration
  • SESSION_*: Session configuration
  • BROADCAST_*: Broadcasting configuration

Email Configuration

For password reset functionality, configure your mail settings in .env:

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

Usage

Starting the Development Server

php artisan serve

The application will be available at http://127.0.0.1:8000.

Common Commands

  • Run tests: php artisan test or ./vendor/bin/phpunit
  • Clear cache: php artisan cache:clear
  • Clear configuration cache: php artisan config:clear
  • Clear route cache: php artisan route:clear
  • Clear view cache: php artisan view:clear
  • Generate application key: php artisan key:generate
  • Run database migrations: php artisan migrate
  • Rollback last migration: php artisan migrate:rollback
  • Seed the database: php artisan db:seed

Authentication Routes

The login system provides the following routes by default:

  • /login - Login page
  • /register - Registration page
  • /password/reset - Password reset request
  • /password/reset/{token} - Password reset form
  • /email/verify - Email verification notice
  • /email/verify/{id}/{hash} - Email verification handler
  • /logout - Logout route

Security Considerations

  • Always use HTTPS in production
  • Sanitize all user inputs
  • Use Laravel's built-in CSRF protection
  • Implement rate limiting for login attempts
  • Regularly update dependencies
  • Use strong passwords and encourage users to do the same
  • Implement proper session management
  • Enable two-factor authentication for added security

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Testing

Run the test suite using:

php artisan test

To run tests with coverage:

php artisan test --coverage

Deployment

  1. Upload project files to your server
  2. Run composer install --no-dev to install production dependencies only
  3. Set proper file permissions
  4. Configure your web server (Apache/Nginx)
  5. Run migrations: php artisan migrate --force
  6. Clear caches: php artisan config:clear, php artisan route:clear, php artisan view:clear
  7. Set up scheduled tasks if needed (cron jobs)

API Documentation

If your login system includes API endpoints, document them here:

API Authentication

Most API endpoints require authentication using Laravel Sanctum or Passport. Include the token in your requests:

Authorization: Bearer {your-token-here}

Available Endpoints

  • POST /api/login - Authenticate user
  • POST /api/logout - Logout user
  • POST /api/register - Register new user
  • GET /api/user - Get authenticated user details

License

This project is licensed under the MIT License.

Support

If you encounter any issues, please open an issue on the GitHub repository or contact the project maintainers.

Acknowledgements

  • Laravel Framework
  • Composer
  • Vite
  • Bootstrap (or other CSS framework used)
  • Font Awesome (if icons used)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages