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

Implement OAuth Authentication (GitHub & Google) and Email/Password Login, Registration Page and Login Page #114

Open
wants to merge 3 commits into
base: feature/webiu-2024
Choose a base branch
from

Conversation

Rajshah1302
Copy link

Description

This PR introduces GitHub OAuth, Google OAuth, and email/password authentication methods across both the frontend and backend.

Frontend:

  • Created a login page with options for GitHub OAuth, Google OAuth, and email/password login.
  • Integrated GitHub and Google OAuth login flows in the frontend, including token handling and user details display after successful login.
  • Added error handling for invalid login credentials and empty fields in the email/password login form.

Backend:

  • Implemented the GitHub OAuth authentication API to handle user login via GitHub, including token exchange and user info retrieval from GitHub.
  • Implemented the Google OAuth authentication API to handle user login via Google, with token exchange and user info retrieval from Google.
  • Created email/password login and registration APIs, including password hashing, email validation, and error handling for missing or incorrect credentials.
  • Updated the user model to store GitHub ID, Google ID, and password.

Database:

  • Modified the user schema to support OAuth credentials (GitHub and Google), in addition to email/password authentication.
  • Ensured secure password storage using bcrypt hashing.

Related Issue

#108

Motivation and Context

This change introduces multiple authentication options to make the application more flexible and secure. By adding OAuth integrations for GitHub and Google alongside the traditional email/password login, users can authenticate via their preferred method. This enhances user experience and makes the application more accessible.


Screenshots (In case of UI changes):

  • Login Page
    image

  • Registration Page:
    image


Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • All new and existing tests have passed and it does not give any unexpected errors.

@Rajshah1302
Copy link
Author

Demo

Webiu.mp4

@Rajshah1302
Copy link
Author

@rajutkarsh07 Please review this PR

@Rajshah1302
Copy link
Author

ENV File Format

To get Google OAuth working, you'll need to generate an mkcert as Google OAuth allows only HTTPS requests.
Here's the .env file setup for the server:

PORT=5100
MONGODB_URI=
JWT_SECRET=
GITHUB_ACCESS_TOKEN=
# Google OAuth
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=

# GitHub OAuth
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_REDIRECT_URI=

SSL_KEY_PATH=
SSL_CERT_PATH=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant