This Django project provides a RESTful API for user management, integrating Firebase authentication and offering endpoints for creating, logging in, retrieving, updating, and deleting user accounts while handle sending email and password reset link using celery as background task.
-
Clone the repository:
git clone https://github.com/Abiorh001/drf_with_firebase_auth.git cd your-repository
-
Install the required packages:
pip install -r requirements.txt
-
Apply migrations:
python manage.py migrate
-
Run the development server:
python manage.py runserver
To handle asynchronous tasks, Celery is used. Open a new terminal window and run the following commands:
-
Start Celery:
python3 -m celery -A drf_with_firebase worker -l info
- URL:
auth/sign-up/
- Method:
POST
- Description: Create a new user by providing the required fields.
- Request Body:
email
(string): User's email address.password
(string): User's password.first_name
(string): User's first name.last_name
(string): User's last name.
- Response:
- Status 201: User created successfully.
- Status 400: User creation failed.
- URL:
auth/sign-in/
- Method:
POST
- Description: Login an existing user by providing the email and password.
- Request Body:
email
(string): User's email address.password
(string): User's password.
- Response:
- Status 200: User logged in successfully.
- Status 404: User does not exist.
- URL:
<pk>/
- Methods:
GET
: Retrieve details of an existing user.PATCH
: Update an existing user's information.DELETE
: Delete an existing user.
- Description: Perform operations on an existing user based on their primary key.
- Response:
- Status 200: User retrieved/updated successfully.
- Status 404: User does not exist.
- URL:
auth/update-email-address/
- Method:
PATCH
- Description: Update an existing user's email address on Firebase and in the database.
- Request Body:
email
(string): New email address.firebase_uid
(string): User's Firebase UID.
- Response:
- Status 200: User email updated successfully.
- Status 400: New email and Firebase UID are required.
- Status 404: User does not exist.
- URL:
auth/reset-password/
- Method:
GET
- Description: Reset an existing user's password by providing the email address.
- Query Parameter:
email
(string): User's email address.
- Response:
- Status 200: Password reset link sent successfully.
- Status 404: User does not exist.