Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Implement Facebook OAuth Login for Users #162

Open
7 tasks
dhamolahedonist opened this issue Jul 23, 2024 · 0 comments
Open
7 tasks

[FEAT] Implement Facebook OAuth Login for Users #162

dhamolahedonist opened this issue Jul 23, 2024 · 0 comments
Assignees
Labels

Comments

@dhamolahedonist
Copy link
Contributor

dhamolahedonist commented Jul 23, 2024

Description:

Implement functionality that allows users to log in via Facebook. This feature should ensure that users can authenticate using their Facebook accounts.

Acceptance Criteria:

API Endpoint Implementation:

  • The endpoint should be accessible at /api/v1/auth/facebook.
  • The endpoint should handle OAuth authentication via Facebook.

Authorization:

  • Ensure that only valid Facebook users can log in.
  • Validate the token received from Facebook to authenticate the user.

User Data Handling:

  • On successful authentication, the user's Facebook profile should be retrieved.
  • If the user is logging in for the first time, create a new user account in the database.
  • If the user already exists, update their profile information accordingly.

Response:

On success: The API should return a 200 OK status code with the user's profile and a JWT token.
On failure: The API should return a 401 Unauthorized status code if the Facebook token is invalid, or a 500 Internal Server Error status code for unexpected errors.

Request Example:

GET /api/v1/auth/facebook
Authorization: Bearer <facebook_token>
Successful Response Example:
{
  "message": "Login successful",
  "status": 200,
  "token": "<jwt_token>",
  "data": {
    "user": {
      "id": "123",
      "name": "John Doe",
      "email": "john.doe@example.com"
     "facebook_id": "1234567890"
      "profile": {
        "id": "123",
        "first_name": "John",
        "last_name": "Doe",
        "phone_number": "1234567890",
        "avatarUrl": "https://example.com/avatar.jpg"
      }
    }
  }
}

Error Response Example:

{
    "message": "Invalid email. Email is required",
    "status_code": 400
}

or

{
  "message": "Authentication failed",
  "status": 401
}

or

{
  "message": "Internal server error",
  "status": 500
}

Purpose:

Enable users to log in using their Facebook accounts, providing a seamless authentication process.

Requirements:

Develop server-side logic to handle Facebook OAuth authentication.
Implement authorization checks to validate the Facebook token.
Ensure user data is properly handled during login and registration.
Expected Outcome:
Users can log in through Facebook, with their profile information being stored or updated in the system.

Status Codes:

200: User successfully authenticated,
401: Invalid email. Email is required,
500: Internal server error

Testing:

Write unit tests to verify that the endpoint correctly handles Facebook authentication.
Test authorization to ensure only valid Facebook users can log in.
Perform integration testing to confirm that user data is obtained and handled correctly during login and registration.

@PreciousIfeaka PreciousIfeaka changed the title [FEAT] Implement Facebook Login for Users [FEAT] Implement Facebook OAuth Login for Users Jul 24, 2024
@PreciousIfeaka PreciousIfeaka self-assigned this Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants