mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-08 17:22:29 +08:00
feat: 🎸 returen missing vars for oauth
This commit is contained in:
parent
332de4e67f
commit
7929aaf91a
@ -31,7 +31,7 @@ function checkAuth(req: Request, res: Response, next: NextFunction) {
|
|||||||
res.redirect('/login');
|
res.redirect('/login');
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
} else if (openID.isOpenIDEnabled()) {
|
} else if (currentSsoStatus) {
|
||||||
if (req.oidc?.isAuthenticated() && req.session.loggedIn) {
|
if (req.oidc?.isAuthenticated() && req.session.loggedIn) {
|
||||||
next();
|
next();
|
||||||
return;
|
return;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import OpenIDError from "../errors/open_id_error.js";
|
|
||||||
import type { NextFunction, Request, Response } from "express";
|
import type { NextFunction, Request, Response } from "express";
|
||||||
import openIDEncryption from "./encryption/open_id_encryption.js";
|
import openIDEncryption from "./encryption/open_id_encryption.js";
|
||||||
import sqlInit from "./sql_init.js";
|
import sqlInit from "./sql_init.js";
|
||||||
@ -8,24 +7,22 @@ import sql from "./sql.js";
|
|||||||
import config from "./config.js";
|
import config from "./config.js";
|
||||||
|
|
||||||
|
|
||||||
function isOpenIDEnabled() {
|
function checkOpenIDConfig() {
|
||||||
if (config.MultiFactorAuthentication.ssoEnabled) {
|
let missingVars: string[] = []
|
||||||
if (config.MultiFactorAuthentication.totpEnabled) {
|
|
||||||
throw new OpenIDError("Cannot enable both OpenID and TOTP!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.MultiFactorAuthentication.oauthBaseUrl === "") {
|
if (config.MultiFactorAuthentication.oauthBaseUrl === "") {
|
||||||
throw new OpenIDError("oauthBaseUrl is undefined!");
|
missingVars.push("oauthBaseUrl");
|
||||||
}
|
}
|
||||||
if (config.MultiFactorAuthentication.oauthClientId === "") {
|
if (config.MultiFactorAuthentication.oauthClientId === "") {
|
||||||
throw new OpenIDError("oauthClientId is undefined!");
|
missingVars.push("oauthClientId");
|
||||||
}
|
}
|
||||||
if (config.MultiFactorAuthentication.oauthClientSecret === "") {
|
if (config.MultiFactorAuthentication.oauthClientSecret === "") {
|
||||||
throw new OpenIDError("oauthClientSecret is undefined!");
|
missingVars.push("oauthClientSecret");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return missingVars;
|
||||||
|
}
|
||||||
|
|
||||||
return config.MultiFactorAuthentication.ssoEnabled;
|
function isOpenIDEnabled() {
|
||||||
|
return checkOpenIDConfig().length > 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUserSaved() {
|
function isUserSaved() {
|
||||||
@ -58,6 +55,7 @@ function getOAuthStatus() {
|
|||||||
name: getUsername(),
|
name: getUsername(),
|
||||||
email: getUserEmail(),
|
email: getUserEmail(),
|
||||||
enabled: isOpenIDEnabled(),
|
enabled: isOpenIDEnabled(),
|
||||||
|
missingVars: checkOpenIDConfig()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user