Skip to content

Abiorh001/drf_with_firebase_auth

Repository files navigation

Django REST Framework API for User Management

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.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/Abiorh001/drf_with_firebase_auth.git
    cd your-repository
  2. Install the required packages:

    pip install -r requirements.txt
  3. Apply migrations:

    python manage.py migrate
  4. Run the development server:

    python manage.py runserver

Running Celery

To handle asynchronous tasks, Celery is used. Open a new terminal window and run the following commands:

  1. Start Celery:

    python3 -m celery -A drf_with_firebase worker -l info 

Endpoints

1. Create a New User

  • 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.

2. Login an Existing User

  • 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.

3. Retrieve, Update, or Delete an Existing User

  • 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.

4. Update an Existing User's Email Address

  • 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.

5. Reset an Existing User's Password

  • 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages