Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

bug fixed

daniel31x132264abd3842b
diff --git a/pages/api/v1/auth/[...nextauth].ts b/pages/api/v1/auth/[...nextauth].ts
index c15f8c72..dd38aa7b 100644
--- a/pages/api/v1/auth/[...nextauth].ts
+++ b/pages/api/v1/auth/[...nextauth].ts
@@ -1200,6 +1200,28 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) {
if (trigger === "signIn" || trigger === "signUp")
token.id = user?.id as number;
+ if (trigger === "signUp") {
+ const checkIfUserExists = await prisma.user.findUnique({
+ where: {
+ id: token.id,
+ },
+ });
+
+ if (checkIfUserExists && !checkIfUserExists.username) {
+ const autoGeneratedUsername =
+ "user" + Math.round(Math.random() * 1000000000);
+
+ await prisma.user.update({
+ where: {
+ id: token.id,
+ },
+ data: {
+ username: autoGeneratedUsername,
+ },
+ });
+ }
+ }
+
return token;
},
async session({ session, token }) {