Skip to content

feat: add GitHub OAuth login option (#37)#43

Open
abhijeetsatpute wants to merge 1 commit intoAnimePub:mainfrom
abhijeetsatpute:feature/github-oauth-login
Open

feat: add GitHub OAuth login option (#37)#43
abhijeetsatpute wants to merge 1 commit intoAnimePub:mainfrom
abhijeetsatpute:feature/github-oauth-login

Conversation

@abhijeetsatpute
Copy link
Contributor

@abhijeetsatpute abhijeetsatpute commented Mar 6, 2026

Summary

Closes #37

  • New OAuth provider: GitHub login added alongside the existing Google option using passport-github2
  • Smart account linking: if a user already has an AniPub account with the same email (email/password or Google), their GitHub ID is linked to that account rather than creating a duplicate
  • Graceful degradation: button only appears when GITHUB_CLIENT_ID + GITHUB_CLIENT_SECRET are set; unconfigured instances show nothing (no broken buttons)
  • Same auth flow: sets the identical anipub JWT cookie and session fields as Google OAuth

Setup

  1. Go to GitHub → Settings → Developer settings → OAuth Apps → New OAuth App
  2. Set Authorization callback URL to https://www.anipub.xyz/auth/github/callback
  3. Copy Client ID and Client Secret into .env

Test plan

  • With env vars unset: GitHub button does not appear on login page
  • With env vars set: "Continue with GitHub" button appears below "Continue with Google"
  • Clicking GitHub button redirects to GitHub authorization page
  • After authorizing: redirected to /Home and logged in
  • User with same email already in DB: no duplicate created, githubId linked
  • Brand new GitHub user: new account created with Active status

- Install passport-github2 and configure GitHub OAuth strategy
- Link GitHub accounts to existing users by email to avoid duplicates
- Add GET /auth/github and /auth/github/callback routes
- Pass githubOauthEnabled to Login page render
- Add GitHub login button to Login.ejs
- Style GitHub button in login.css matching existing Google button
- Add GITHUB_CLIENT_ID/SECRET/CALLBACK_URL to .env.example
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.

Add Github Login Option in the Login Page

1 participant