Skip to content

feat: implement Google OAuth 2.0 sign-in #1145#1163

Open
anushkagupta200615-jpg wants to merge 1 commit into
Charushi06:mainfrom
anushkagupta200615-jpg:feat/google-oauth
Open

feat: implement Google OAuth 2.0 sign-in #1145#1163
anushkagupta200615-jpg wants to merge 1 commit into
Charushi06:mainfrom
anushkagupta200615-jpg:feat/google-oauth

Conversation

@anushkagupta200615-jpg

Copy link
Copy Markdown

Related Issue

Closes #ISSUE_NUMBER

Summary

Brief explanation of the contribution.

Changes Made

  • Bullet list of implemented changes.
  • ...

Testing

Explain how the changes were tested.

Screenshots

Add screenshots if UI changes exist.

Checklist

  • Code follows project style
  • Tested locally
  • No unrelated changes included
  • Documentation updated (if applicable)

Resolves #1145

Description

This PR resolves the requested feature by implementing Google OAuth 2.0 Sign-In and session management using JSON Web Tokens (JWT).

Changes Included

  • Frontend: Added the Google Identity Services snippet and an official Google Sign-In button inside the existing auth-modal on index.html. It intercepts the successful login and forwards the token to the backend.
  • Backend Verification: Implemented the /api/auth/google endpoint utilizing google-auth-library to securely verify the incoming token using Google's public keys.
  • Session Management (JWT): Replaced the basic local login system with JWT-based session management, issuing 7-day tokens upon both Google and local logins.
  • SQLite Database Support: Rather than introducing an entirely new MongoDB dependency just for users as suggested in the issue, a native users table was added inside the existing studyplan.db using SQLite to seamlessly store the Google profile data (email, name, picture, auth_provider) alongside the existing tasks and subjects.

How to Test

  1. Set the GOOGLE_CLIENT_ID and JWT_SECRET in your .env file.
  2. Run npm install to grab the newly added jsonwebtoken and google-auth-library dependencies.
  3. Start the server via npm start.
  4. Open the site, hit Sign In, and utilize the Google login button. Upon a successful login, an account will be created under the users table in SQLite and the session token will be saved to your local storage.

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.

feat: Add signup/signin with Google functionality features

1 participant