This commit is contained in:
daniel31x13 2024-08-19 19:25:13 -04:00
parent 03b4240b8b
commit 495509c888
2 changed files with 19 additions and 3 deletions

View File

@ -8,7 +8,7 @@ const InstallApp = (props: Props) => {
const [isOpen, setIsOpen] = useState(true);
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">
<svg
xmlns="http://www.w3.org/2000/svg"

View File

@ -1179,14 +1179,14 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) {
},
callbacks: {
async signIn({ user, account, profile, email, credentials }) {
if (account?.provider !== "credentials") {
if (account?.provider !== "credentials" && newSsoUsersDisabled) {
// registration via SSO can be separately disabled
const existingUser = await prisma.account.findFirst({
where: {
providerAccountId: account?.providerAccountId,
},
});
if (!existingUser && newSsoUsersDisabled) {
if (!existingUser) {
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;