-
Notifications
You must be signed in to change notification settings - Fork 33
Added check if the Google OAuth account has e-mail verified flag #152
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Changes !== false to !== true to fail closed if verification field is missing, null, or false. Prevents bypass attacks.
} | ||
|
||
// If we get here, the check passed | ||
return { verified: true, provider } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// Check email verification only for new users (signup) | ||
// Existing users with linked identities can sign in with any provider | ||
const isNewUser = data.user.identities?.length === 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: OAuth Users Blocked by Incorrect New User Check
The isNewUser
check, based on data.user.identities?.length === 1
, incorrectly identifies existing users with a single OAuth identity as new. This subjects existing users to email verification checks, potentially blocking their sign-in if their OAuth provider's email verification status isn't met.
Agreed with Ben, we will not merge this in favor of possible other mitigations. |
Summary
Implements email verification validation for OAuth providers during authentication callback. Users with unverified emails are rejected and signed out.
Changes
isOAuthEmailVerified()
helper function to validate OAuth identity dataBehavior
email_verified
) and GitHub (verified
) providersTesting
Verified locally with Google OAuth. Logs confirm check executes on every OAuth authentication.
Note
Adds OAuth email verification at auth callback for new users, with provider-specific error handling and messages.
src/app/api/auth/callback/route.ts
):isOAuthEmailVerified
; treat users with a single identity as new.signOut
, and redirect toAUTH_URLS.SIGN_IN
with provider-specific error message fromUSER_MESSAGES
.src/lib/utils/auth.ts
):isOAuthEmailVerified(user)
to check identity data (supportsgoogle
viaemail_verified
andgithub
viaverified
).src/configs/user-messages.ts
):googleEmailNotVerified
,githubEmailNotVerified
,oauthEmailNotVerified
, andgenericEmailNotVerified
with 30s timeouts.Written by Cursor Bugbot for commit 64f1a03. This will update automatically on new commits. Configure here.