Skip to content

Oauth2 - #3

Merged
upayanmazumder merged 6 commits into
mainfrom
oauth2
Dec 22, 2025
Merged

Oauth2#3
upayanmazumder merged 6 commits into
mainfrom
oauth2

Conversation

@upayanmazumder

Copy link
Copy Markdown
Collaborator

This pull request introduces comprehensive support for Google OAuth login and account linking, enhances user authentication flows, and updates the database schema to support hybrid authentication methods. The changes also improve error handling, session management, and environment configuration for both local and production deployments.

OAuth and Authentication Enhancements

  • Added Google OAuth login and account linking, including support for hybrid accounts (users can log in with either password or Google) and blocking password login for Google-only accounts. (api/src/controllers/authController.ts [1] api/src/models/user.ts [2] api/src/passport.ts [3] api/src/routes/auth.ts [4]
  • Improved Google OAuth callback error handling and redirect logic, including support for linking Google accounts to existing users and clear user feedback on errors. (api/src/controllers/authController.ts api/src/controllers/authController.tsL162-R208)
  • Updated user model and API responses to include new fields: auth_provider, google_id, oauth_connected, and updated_at. (api/src/models/user.ts [1] api/src/controllers/authController.ts [2]

Database Schema Updates

  • Modified the users table to support nullable password_hash, added columns for OAuth (auth_provider, google_id, oauth_connected, updated_at), and included migration logic to handle existing databases gracefully. (api/src/server.ts api/src/server.tsL63-R142)
  • Added index on google_id for efficient lookups and improved session table initialization with robust error handling for permission issues. (api/src/server.ts [1] [2]

Environment and Configuration Improvements

  • Introduced API_URL in environment files and refactored config logic to automatically construct API URLs for different environments. (api/example.env [1] api/src/config.ts [2]
  • Updated Google OAuth callback URL logic to use the new API URL when not explicitly set. (api/src/config.ts api/src/config.tsL19-R33)
  • Added new environment variables for frontend authentication and deployment. (app/example.env app/example.envR3-R7)

Session and Cookie Management

  • Standardized cookie domain logic for cross-subdomain authentication in production across controllers and server configuration. (api/src/controllers/authController.ts [1] [2] [3] api/src/routes/auth.ts [4] api/src/server.ts [5]
  • Extended session data types to support OAuth linking state. (api/src/server.ts api/src/server.tsR14-R19)

Security and Error Handling

  • Improved error handling and logging for authentication failures, database permission issues, and session management to provide clearer diagnostics and user feedback. (api/src/controllers/authController.ts [1] api/src/server.ts [2] [3]

These changes collectively provide robust, flexible authentication and account management for both local and OAuth users, while ensuring smooth migrations and clear error reporting.

…ntegration

- Added Google OAuth button to the registration page for easier signup.
- Improved user feedback during registration and profile loading states.
- Updated profile component to handle Google account linking and unlinking.
- Enhanced error handling and user notifications for authentication processes.
- Refactored API utility functions to include Google account management.
@upayanmazumder upayanmazumder self-assigned this Dec 22, 2025
@upayanmazumder
upayanmazumder merged commit 8dc2203 into main Dec 22, 2025
2 checks passed
@upayanmazumder
upayanmazumder deleted the oauth2 branch December 22, 2025 20:30
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