mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-27 17:36:42 -05:00
fix(generic-oauth): should check for email after mapProfileToUser
This commit is contained in:
@@ -602,16 +602,16 @@ export const genericOAuth = (options: GenericOAuthOptions) => {
|
||||
? await provider.getUserInfo(tokens)
|
||||
: await getUserInfo(tokens, finalUserInfoUrl)
|
||||
) as User | null;
|
||||
|
||||
if (!userInfo?.email) {
|
||||
ctx.context.logger.error("Unable to get user info", userInfo);
|
||||
throw redirectOnError("email_is_missing");
|
||||
if (!userInfo) {
|
||||
throw redirectOnError("user_info_is_missing");
|
||||
}
|
||||
|
||||
const mapUser = provider.mapProfileToUser
|
||||
? await provider.mapProfileToUser(userInfo)
|
||||
: null;
|
||||
|
||||
if (!mapUser?.email) {
|
||||
ctx.context.logger.error("Unable to get user info", userInfo);
|
||||
throw redirectOnError("email_is_missing");
|
||||
}
|
||||
if (link) {
|
||||
if (
|
||||
ctx.context.options.account?.accountLinking
|
||||
|
||||
Reference in New Issue
Block a user