feat: 🎸 Remove redundant func

This commit is contained in:
Jin
2025-03-26 01:58:54 +01:00
parent 886e63f128
commit 4762287d61
2 changed files with 18 additions and 23 deletions

View File

@@ -61,7 +61,7 @@ app.use(`/icon.png`, express.static(path.join(scriptDir, "public/icon.png")));
app.use(sessionParser);
app.use(favicon(`${scriptDir}/../images/app-icons/icon.ico`));
if (openID.checkOpenIDRequirements())
if (openID.isOpenIDEnabled())
app.use(auth(openID.generateOAuthConfig()));
await assets.register(app);

View File

@@ -9,7 +9,23 @@ import config from "./config.js";
function isOpenIDEnabled() {
return checkOpenIDRequirements();
if (config.MultiFactorAuthentication.ssoEnabled) {
if (config.MultiFactorAuthentication.totpEnabled) {
throw new OpenIDError("Cannot enable both OpenID and TOTP!");
}
if (config.MultiFactorAuthentication.oauthBaseUrl === "") {
throw new OpenIDError("oauthBaseUrl is undefined!");
}
if (config.MultiFactorAuthentication.oauthClientId === "") {
throw new OpenIDError("oauthClientId is undefined!");
}
if (config.MultiFactorAuthentication.oauthClientSecret === "") {
throw new OpenIDError("oauthClientSecret is undefined!");
}
}
return config.MultiFactorAuthentication.ssoEnabled;
}
function isUserSaved() {
@@ -36,26 +52,6 @@ function clearSavedUser() {
};
}
function checkOpenIDRequirements() {
if (config.MultiFactorAuthentication.ssoEnabled) {
if (config.MultiFactorAuthentication.totpEnabled) {
throw new OpenIDError("Cannot enable both OpenID and TOTP!");
}
if (config.MultiFactorAuthentication.oauthBaseUrl === "") {
throw new OpenIDError("oauthBaseUrl is undefined!");
}
if (config.MultiFactorAuthentication.oauthClientId === "") {
throw new OpenIDError("oauthClientId is undefined!");
}
if (config.MultiFactorAuthentication.oauthClientSecret === "") {
throw new OpenIDError("oauthClientSecret is undefined!");
}
}
return config.MultiFactorAuthentication.ssoEnabled;
}
function getOAuthStatus() {
return {
success: true,
@@ -145,7 +141,6 @@ export default {
getOAuthStatus,
isOpenIDEnabled,
clearSavedUser,
checkOpenIDRequirements,
isTokenValid,
isUserSaved,
};