This project implements a user authentication system where users can register, login, and manage their profiles. The system supports login via OTP (One-Time Password) sent to the user's email as well as traditional username and password login. The frontend is built with React.js, and the backend is powered by Django and Django Rest Framework.
This project implements a user authentication system with the following features:
- User registration with a unique username, email, and password.
- Login using an OTP sent to the user's email.
- Login using a username and password.
- Profile management where users can update their full name and bio.
- Secure handling of user data and authentication.
- Django: Web framework for building the backend application.
- Django Rest Framework: For building RESTful APIs.
- PostgreSQL: Database engine.
- pydantic_settings: For environment variable validation.
- gunicorn: WSGI HTTP Server for UNIX.
- django.core.mail: For sending OTP emails.
- Redis: For storing OTPs with expiration.
- CustomUser: Extends Django's AbstractUser model.
- Fields:
username
,email
,password
, etc.
- Fields:
- Profile: Stores additional user information.
- Fields:
user_id
(foreign key to CustomUser),full_name
,bio
.
- Fields:
- User Registration:
POST /users/
- Registers a new user.
- Generate OTP:
POST /generate-otp/
- Sends an OTP to the user's email.
- Login with OTP:
POST /login/
- Logs in a user using the OTP.
- Login with Username and Password:
POST /login/username/
- Logs in a user using their username and password.
- Profile Management:
GET /profile/<user_id>/
,PUT /profile/<user_id>/
- Retrieve and update user profile.
- React.js: JavaScript library for building user interfaces.
- React Router: For routing and navigation.
- CSS: For styling the components.
- AuthForm: Handles switching between login and signup forms.
- LoginForm: Manages login via OTP and username/password.
- SignUpForm: Manages user registration.
- Profile: Displays and allows updates to the user profile.
TODO: Add docker-compose.yml
- Clone the repository:
git clone https://github.com/quantum-ernest/user_auth.git cd user_auth/api/
- Install Dependencies: Make sure to setup Redis and Postgresql
pip install -r requirements.txt
- Create .env file from user_auth/api/env.example.txt
- Run migrations:
python manage.py migrate
- Start dev server:
python manage.py runserver
- Navigate to the front directory:
cd user_auth/front/
- Install dependencies
npm install
- Start dev server
npm start