feat: refactored login

This commit is contained in:
Sebastian Hierholzer
2023-12-03 21:01:28 +01:00
parent 93e4897c0b
commit 361795ed47
7 changed files with 1624 additions and 260 deletions
File diff suppressed because it is too large Load Diff
+31
View File
@@ -0,0 +1,31 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import * as process from "process";
export type ResponseData = {
credentialsEnabled: string|undefined
emailEnabled: string|undefined
registrationDisabled: string|undefined
buttonAuths: {
method: string
name: string
}[]
}
export default function handler(req: NextApiRequest, res: NextApiResponse<ResponseData>) {
res.json(getLogins());
}
export function getLogins() {
const buttonAuths = []
if (process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED === 'true') {
buttonAuths.push({method: 'keycloak', name: 'Keycloak'});
}
if (process.env.NEXT_PUBLIC_AUTHENTIK_ENABLED === 'true') {
buttonAuths.push({method: 'authentik', name: process.env.AUTHENTIK_CUSTOM_NAME ?? 'Authentik'});
}
return {
credentialsEnabled: (process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED === 'true' || process.env.NEXT_PUBLIC_CREDENTIALS_ENABLED === undefined) ? "true" : "false",
emailEnabled: process.env.NEXT_PUBLIC_EMAIL_PROVIDER,
registrationDisabled: process.env.NEXT_PUBLIC_DISABLE_REGISTRATION,
buttonAuths: buttonAuths
};
}