feat: basic support for Keycloak (OIDC)

This commit is contained in:
Tomáš Hruška
2023-11-09 11:41:08 +01:00
parent 518b94b1f4
commit 946eed3773
8 changed files with 122 additions and 10 deletions
+22
View File
@@ -12,6 +12,7 @@ interface FormData {
}
const emailEnabled = process.env.NEXT_PUBLIC_EMAIL_PROVIDER;
const keycloakEnabled = process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED;
export default function Login() {
const [submitLoader, setSubmitLoader] = useState(false);
@@ -47,6 +48,18 @@ export default function Login() {
}
}
async function loginUserKeycloak() {
setSubmitLoader(true);
const load = toast.loading("Authenticating...");
const res = await signIn("keycloak", {});
toast.dismiss(load);
setSubmitLoader(false);
}
return (
<CenteredForm text="Sign in to your account">
<form onSubmit={loginUser}>
@@ -102,6 +115,15 @@ export default function Login() {
className=" w-full text-center"
loading={submitLoader}
/>
{process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED === "true" ? (
<SubmitButton
type="button"
onClick={loginUserKeycloak}
label="Sign in with Keycloak"
className=" w-full text-center"
loading={submitLoader}
/>
) : undefined}
{process.env.NEXT_PUBLIC_DISABLE_REGISTRATION ===
"true" ? undefined : (
<div className="flex items-baseline gap-1 justify-center">