Skip to content

Build your personal knowledge base with Trilium Notes

feat: 🎸 Remove redundant func

Jin4762287d6184
diff --git a/src/app.ts b/src/app.ts
index 171ac9222a..326c15efdd 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -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);
diff --git a/src/services/open_id.ts b/src/services/open_id.ts
index 6515fa5ec0..1a9b7b1b99 100644
--- a/src/services/open_id.ts
+++ b/src/services/open_id.ts
@@ -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,
};