allow only registered publishers to set up local credentials; fix menu; fix signin UI

This commit is contained in:
Dobromir Popov
2024-04-30 13:15:37 +03:00
parent 8f7446d214
commit ad42fbf639
3 changed files with 38 additions and 20 deletions

View File

@ -108,18 +108,24 @@ export const authOptions: NextAuthOptions = {
}
}
else {
throw new Error("Не можем да намерим твоя имейл '" + credentials?.username + "' в участниците в ССОМ. Моля свържи се с нас за да те регистрираме ако искаш да ползваш този имейл.");
// console.log("Creating new user in the database...");
// const passHash = await bcrypt.hash(credentials.password, 10);
// const newUser = await prisma.user.create({
// data: {
// name: credentials.username,
// email: credentials.username,
// passwordHashLocalAccount: passHash
// }
// });
// console.log("New user created in the database.");
// return newUser;
const pub = await prisma.publisher.findUnique({ where: { email: credentials.username } });
if (pub) {
const passHash = await bcrypt.hash(credentials.password, 10);
const newUser = await prisma.user.create({
data: {
name: credentials.username,
email: credentials.username,
passwordHashLocalAccount: passHash
}
});
console.log("New local credential user created for publisher ", pub.firstName, " ", pub.lastName, " (", pub.email, ")");
return newUser;
}
else {
throw new Error("Не можем да намерим твоя имейл '" + credentials?.username + "' в участниците в ССОМ. Моля свържи се с нас за да те регистрираме ако искаш да ползваш този имейл.");
}
}
}
}