mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
feat: 🎸 Remove redundant func
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user