Skip to content

feat: user database schema OAuth fields + Google authentication#113

Open
Depo-dev wants to merge 3 commits into
amina69:mainfrom
Depo-dev:feat/user-schema-and-google-auth
Open

feat: user database schema OAuth fields + Google authentication#113
Depo-dev wants to merge 3 commits into
amina69:mainfrom
Depo-dev:feat/user-schema-and-google-auth

Conversation

@Depo-dev
Copy link
Copy Markdown

@Depo-dev Depo-dev commented Jun 2, 2026

Summary

  • Issue Create User Database Schema #105 - User DB Schema: Extends the existing User model with OAuth support: password is now nullable (for OAuth-only accounts), adds an AuthProvider enum (LOCAL/GOOGLE), and provider/providerId fields for multi-provider design. The existing avatarUrl field already covers profileImage. firstName/lastName cover fullName. All other required fields (id, email, createdAt, updatedAt, unique email index) were already production-ready.
  • Issue Google Authentication Implementation #104 - Google Auth: Implements full Google OAuth 2.0 sign-in/sign-up via passport-google-oauth20. New users are auto-created on first Google login; existing local accounts are linked if they share the same email. Returns a JWT identical to the local login flow.

Changes

File What changed
prisma/schema.prisma AuthProvider enum; password nullable; provider/providerId fields on User
src/auth/auth.service.ts googleLogin() method - upsert logic for Google users
src/auth/strategies/google.strategy.ts New - passport-google-oauth20 Passport strategy
src/auth/guards/google-auth.guard.ts New - GoogleAuthGuard
src/auth/auth.controller.ts GET /auth/google and GET /auth/google/callback endpoints
src/auth/auth.module.ts Register GoogleStrategy as provider
package.json Add passport-google-oauth20 + @types/passport-google-oauth20
.env.example Document GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, GOOGLE_CALLBACK_URL

Test plan

  • npm install picks up passport-google-oauth20
  • npx prisma migrate dev applies the schema changes without errors
  • GET /auth/google redirects to Google consent screen
  • Completing Google OAuth flow returns { access_token, user } from /auth/google/callback
  • New Google users are created in DB with provider=GOOGLE
  • Existing local user with matching email gets provider/providerId linked on Google login
  • Local POST /auth/login still rejects accounts with no password (OAuth-only users)

Closes #104
Closes #105

- Make User.password nullable to support OAuth-only accounts
- Add AuthProvider enum (LOCAL/GOOGLE) and provider/providerId fields
  to the User model for multi-provider support
- Add GoogleStrategy using passport-google-oauth20 to handle the
  OAuth 2.0 flow (sign-up and sign-in via Google)
- Add GoogleAuthGuard and /auth/google + /auth/google/callback endpoints
- AuthService.googleLogin upserts users: creates new accounts on first
  Google login, links Google to existing local accounts where missing
- Add passport-google-oauth20 and type declarations to package.json
- Document GOOGLE_CLIENT_ID/SECRET/CALLBACK_URL in .env.example

Closes amina69#104
Closes amina69#105
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 2, 2026

@Depo-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Create User Database Schema Google Authentication Implementation

1 participant