allow only registered publishers to set up local credentials; fix menu; fix signin UI
This commit is contained in:
@ -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 + "' в участниците в ССОМ. Моля свържи се с нас за да те регистрираме ако искаш да ползваш този имейл.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user