allow only registered publishers to set up local credentials; fix menu; fix signin UI
This commit is contained in:
@ -217,13 +217,24 @@ function FooterSection() {
|
||||
|
||||
return (
|
||||
footerMenu.map((item, index) => (
|
||||
item.roles ? (
|
||||
<ProtectedRoute key={index} allowedRoles={item.roles} deniedMessage="">
|
||||
<div
|
||||
key={index}
|
||||
className="px-4 py-1 mt-2 cursor-pointer hover:underline hover:text-blue-600 dark:hover:text-blue-400 "
|
||||
className="px-4 py-1 mt-2 cursor-pointer hover:underline hover:text-blue-600 dark:hover:text-blue-400"
|
||||
onClick={() => navigateTo(item.url)}
|
||||
>
|
||||
<span className="text-gray-700 dark:text-gray-300 font-medium">{item.text}</span>
|
||||
</div>
|
||||
</ProtectedRoute>
|
||||
) : (
|
||||
<div
|
||||
key={index}
|
||||
className="px-4 py-1 mt-2 cursor-pointer hover:underline hover:text-blue-600 dark:hover:text-blue-400"
|
||||
onClick={() => navigateTo(item.url)}
|
||||
>
|
||||
<span className="text-gray-700 dark:text-gray-300 font-medium">{item.text}</span>
|
||||
</div>
|
||||
)
|
||||
))
|
||||
);
|
||||
}
|
||||
|
@ -108,18 +108,24 @@ export const authOptions: NextAuthOptions = {
|
||||
}
|
||||
}
|
||||
else {
|
||||
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 + "' в участниците в ССОМ. Моля свържи се с нас за да те регистрираме ако искаш да ползваш този имейл.");
|
||||
// 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,13 +47,14 @@ export default function SignIn({ csrfToken }) {
|
||||
<div className="signin">
|
||||
<div className="min-h-screen flex flex-col items-center justify-center">
|
||||
{/* SSO Providers */}
|
||||
<div className="space-y-4 w-full px-4">
|
||||
<div className="mt-8 w-full max-w-xs px-4">
|
||||
<button onClick={() => signIn('google', { callbackUrl: '/' })}
|
||||
className="flex items-center justify-center w-full py-2 px-4 border border-gray-300 rounded shadow-sm text-sm text-gray-700 bg-white hover:bg-gray-50">
|
||||
<img loading="lazy" height="24" width="24" alt="Google logo"
|
||||
src="https://authjs.dev/img/providers/google.svg" className="mr-2" />
|
||||
Влез чрез Google
|
||||
</button>
|
||||
|
||||
{/* Add more buttons for other SSO providers here in similar style */}
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user