Hotfix/account provider should be lowercase (#7763)
* Fix passThrough console error (passHref is not valid) * Fix 'use-identity-login' error when logging in with idP --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com>pull/7779/head
parent
4308ea8d52
commit
2685e8154f
|
@ -43,7 +43,7 @@ export default function Logout(props: Props) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Button href="/auth/login" passHref className="flex w-full justify-center">
|
<Button href="/auth/login" className="flex w-full justify-center">
|
||||||
{t("go_back_login")}
|
{t("go_back_login")}
|
||||||
</Button>
|
</Button>
|
||||||
</AuthContainer>
|
</AuthContainer>
|
||||||
|
|
|
@ -444,7 +444,7 @@ export const AUTH_OPTIONS: AuthOptions = {
|
||||||
identityProvider: idP,
|
identityProvider: idP,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
identityProviderId: account.providerAccountId as string,
|
identityProviderId: account.providerAccountId,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -523,11 +523,11 @@ export const AUTH_OPTIONS: AuthOptions = {
|
||||||
return "/auth/error?error=unverified-email";
|
return "/auth/error?error=unverified-email";
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingUser = await prisma.user.findFirst({
|
let existingUser = await prisma.user.findFirst({
|
||||||
include: {
|
include: {
|
||||||
accounts: {
|
accounts: {
|
||||||
where: {
|
where: {
|
||||||
provider: idP,
|
provider: account.provider,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -537,6 +537,33 @@ export const AUTH_OPTIONS: AuthOptions = {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* --- START FIX LEGACY ISSUE WHERE 'identityProviderId' was accidentally set to userId --- */
|
||||||
|
if (!existingUser) {
|
||||||
|
existingUser = await prisma.user.findFirst({
|
||||||
|
include: {
|
||||||
|
accounts: {
|
||||||
|
where: {
|
||||||
|
provider: account.provider,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
identityProvider: idP,
|
||||||
|
identityProviderId: String(user.id),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (existingUser) {
|
||||||
|
await prisma.user.update({
|
||||||
|
where: {
|
||||||
|
id: existingUser?.id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
identityProviderId: account.providerAccountId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --- END FIXES LEGACY ISSUE WHERE 'identityProviderId' was accidentally set to userId --- */
|
||||||
if (existingUser) {
|
if (existingUser) {
|
||||||
// In this case there's an existing user and their email address
|
// In this case there's an existing user and their email address
|
||||||
// hasn't changed since they last logged in.
|
// hasn't changed since they last logged in.
|
||||||
|
@ -617,7 +644,7 @@ export const AUTH_OPTIONS: AuthOptions = {
|
||||||
emailVerified: new Date(Date.now()),
|
emailVerified: new Date(Date.now()),
|
||||||
name: user.name,
|
name: user.name,
|
||||||
identityProvider: idP,
|
identityProvider: idP,
|
||||||
identityProviderId: String(user.id),
|
identityProviderId: account.providerAccountId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -640,7 +667,7 @@ export const AUTH_OPTIONS: AuthOptions = {
|
||||||
password: null,
|
password: null,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
identityProvider: idP,
|
identityProvider: idP,
|
||||||
identityProviderId: String(user.id),
|
identityProviderId: account.providerAccountId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (existingUserWithEmail.twoFactorEnabled) {
|
if (existingUserWithEmail.twoFactorEnabled) {
|
||||||
|
@ -664,7 +691,7 @@ export const AUTH_OPTIONS: AuthOptions = {
|
||||||
name: user.name,
|
name: user.name,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
identityProvider: idP,
|
identityProvider: idP,
|
||||||
identityProviderId: String(user.id),
|
identityProviderId: account.providerAccountId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue