This API provides user authentication functionalities, allowing users to register, login, logout, and reset their passwords. It utilizes Flask framework for building the API endpoints and SQLAlchemy for database interactions.
- User Registration: Users can create new accounts by providing their firstname, lastname, email, and password.
- User Login: Registered users can log in using their email and password.
- User Logout: Users can log out, which invalidates their authentication token.
- Forgot Password: Users can request a password reset email if they forget their password.
- Reset Password: Users can reset their password by following a link sent via email.
-
Clone the repository:
git clone https://github.com/Sheila-nk/user-authentication-system.git
-
Navigate to the project directory:
cd user-authentication-api
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables Refer to .env-example for instructions on setting up a
.env
file.Once created, execute the following command:
source .env
-
Generate database migrations (if there are new changes to the models, otherwise skip to step 7):
flask db migrate
-
Apply migrations to the database:
flask db upgrade
-
Run the Flask application:
flask run
- Clone the repository:
git clone https://github.com/Sheila-nk/user-authentication-system.git
- Navigate to the project directory:
cd user-authentication-api
- Build the Docker image:
docker build -t user-authentication .
- Run the Docker container:
docker run -p 5001:5001 user-authentication
POST /auth/register
: Register a new user.POST /auth/login
: Log in an existing user.POST /auth/logout
: Log out a user.POST /auth/forgotpassword
: Request a password reset email.POST /auth/resetpassword
: Reset user password.
POST /auth/register
Content-Type: application/json
{
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]",
"password": "password123"
}
POST /auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "password123"
}
POST /auth/logout
Authorization: Bearer <auth_token>
POST /auth/forgotpassword
Content-Type: application/json
{
"email": "[email protected]"
}
POST /auth/resetpassword
Authorization: Bearer <auth_token>
Content-Type: application/json
{
"password": "newpassword123"
}
Feel free to customize this template according to your specific API implementation and requirements!