mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-11-02 14:12:42 +08:00
feat: 🎸 Remove redundant func
This commit is contained in:
parent
886e63f128
commit
4762287d61
@ -61,7 +61,7 @@ app.use(`/icon.png`, express.static(path.join(scriptDir, "public/icon.png")));
|
|||||||
app.use(sessionParser);
|
app.use(sessionParser);
|
||||||
app.use(favicon(`${scriptDir}/../images/app-icons/icon.ico`));
|
app.use(favicon(`${scriptDir}/../images/app-icons/icon.ico`));
|
||||||
|
|
||||||
if (openID.checkOpenIDRequirements())
|
if (openID.isOpenIDEnabled())
|
||||||
app.use(auth(openID.generateOAuthConfig()));
|
app.use(auth(openID.generateOAuthConfig()));
|
||||||
|
|
||||||
await assets.register(app);
|
await assets.register(app);
|
||||||
|
|||||||
@ -9,7 +9,23 @@ import config from "./config.js";
|
|||||||
|
|
||||||
|
|
||||||
function isOpenIDEnabled() {
|
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() {
|
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() {
|
function getOAuthStatus() {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@ -145,7 +141,6 @@ export default {
|
|||||||
getOAuthStatus,
|
getOAuthStatus,
|
||||||
isOpenIDEnabled,
|
isOpenIDEnabled,
|
||||||
clearSavedUser,
|
clearSavedUser,
|
||||||
checkOpenIDRequirements,
|
|
||||||
isTokenValid,
|
isTokenValid,
|
||||||
isUserSaved,
|
isUserSaved,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user