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 (
|
return (
|
||||||
footerMenu.map((item, index) => (
|
footerMenu.map((item, index) => (
|
||||||
<div
|
item.roles ? (
|
||||||
key={index}
|
<ProtectedRoute key={index} allowedRoles={item.roles} deniedMessage="">
|
||||||
className="px-4 py-1 mt-2 cursor-pointer hover:underline hover:text-blue-600 dark:hover:text-blue-400 "
|
<div
|
||||||
onClick={() => navigateTo(item.url)}
|
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>
|
<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 {
|
else {
|
||||||
throw new Error("Не можем да намерим твоя имейл '" + credentials?.username + "' в участниците в ССОМ. Моля свържи се с нас за да те регистрираме ако искаш да ползваш този имейл.");
|
const pub = await prisma.publisher.findUnique({ where: { email: credentials.username } });
|
||||||
// console.log("Creating new user in the database...");
|
if (pub) {
|
||||||
// const passHash = await bcrypt.hash(credentials.password, 10);
|
const passHash = await bcrypt.hash(credentials.password, 10);
|
||||||
// const newUser = await prisma.user.create({
|
const newUser = await prisma.user.create({
|
||||||
// data: {
|
data: {
|
||||||
// name: credentials.username,
|
name: credentials.username,
|
||||||
// email: credentials.username,
|
email: credentials.username,
|
||||||
// passwordHashLocalAccount: passHash
|
passwordHashLocalAccount: passHash
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// console.log("New user created in the database.");
|
console.log("New local credential user created for publisher ", pub.firstName, " ", pub.lastName, " (", pub.email, ")");
|
||||||
// return newUser;
|
return newUser;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
throw new Error("Не можем да намерим твоя имейл '" + credentials?.username + "' в участниците в ССОМ. Моля свържи се с нас за да те регистрираме ако искаш да ползваш този имейл.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,13 +47,14 @@ export default function SignIn({ csrfToken }) {
|
|||||||
<div className="signin">
|
<div className="signin">
|
||||||
<div className="min-h-screen flex flex-col items-center justify-center">
|
<div className="min-h-screen flex flex-col items-center justify-center">
|
||||||
{/* SSO Providers */}
|
{/* 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: '/' })}
|
<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">
|
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"
|
<img loading="lazy" height="24" width="24" alt="Google logo"
|
||||||
src="https://authjs.dev/img/providers/google.svg" className="mr-2" />
|
src="https://authjs.dev/img/providers/google.svg" className="mr-2" />
|
||||||
Влез чрез Google
|
Влез чрез Google
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{/* Add more buttons for other SSO providers here in similar style */}
|
{/* Add more buttons for other SSO providers here in similar style */}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user