bug fix
This commit is contained in:
parent
03b4240b8b
commit
495509c888
|
@ -8,7 +8,7 @@ const InstallApp = (props: Props) => {
|
||||||
const [isOpen, setIsOpen] = useState(true);
|
const [isOpen, setIsOpen] = useState(true);
|
||||||
|
|
||||||
return isOpen && !isPWA() ? (
|
return isOpen && !isPWA() ? (
|
||||||
<div className="fixed left-0 right-0 bottom-10 w-full p-5">
|
<div className="fixed left-0 right-0 bottom-10 w-full">
|
||||||
<div className="mx-auto w-fit p-2 flex justify-between gap-2 items-center border border-neutral-content rounded-xl bg-base-300 backdrop-blur-md bg-opacity-80 max-w-md">
|
<div className="mx-auto w-fit p-2 flex justify-between gap-2 items-center border border-neutral-content rounded-xl bg-base-300 backdrop-blur-md bg-opacity-80 max-w-md">
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
|
|
@ -1179,14 +1179,14 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) {
|
||||||
},
|
},
|
||||||
callbacks: {
|
callbacks: {
|
||||||
async signIn({ user, account, profile, email, credentials }) {
|
async signIn({ user, account, profile, email, credentials }) {
|
||||||
if (account?.provider !== "credentials") {
|
if (account?.provider !== "credentials" && newSsoUsersDisabled) {
|
||||||
// registration via SSO can be separately disabled
|
// registration via SSO can be separately disabled
|
||||||
const existingUser = await prisma.account.findFirst({
|
const existingUser = await prisma.account.findFirst({
|
||||||
where: {
|
where: {
|
||||||
providerAccountId: account?.providerAccountId,
|
providerAccountId: account?.providerAccountId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!existingUser && newSsoUsersDisabled) {
|
if (!existingUser) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1217,6 +1217,22 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else if (trigger === "signIn") {
|
||||||
|
const user = await prisma.user.findUnique({
|
||||||
|
where: {
|
||||||
|
id: token.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (user && !user.username) {
|
||||||
|
const autoGeneratedUsername =
|
||||||
|
"user" + Math.round(Math.random() * 1000000000);
|
||||||
|
|
||||||
|
await prisma.user.update({
|
||||||
|
where: { id: user.id },
|
||||||
|
data: { username: autoGeneratedUsername },
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
|
|
Ŝarĝante…
Reference in New Issue