refactor(server/utils): isElectron - replace fn with boolean

this values cannot change during runtime,
=> there is no need to have these checks
as dynamic function, instead just
export the boolean value directly
This commit is contained in:
Panagiotis Papadopoulos
2025-01-22 18:57:06 +01:00
parent 94411cf418
commit ca2bb94200
16 changed files with 33 additions and 40 deletions

View File

@@ -14,7 +14,7 @@ const noAuthentication = config.General && config.General.noAuthentication === t
function checkAuth(req: Request, res: Response, next: NextFunction) {
if (!sqlInit.isDbInitialized()) {
res.redirect("setup");
} else if (!req.session.loggedIn && !isElectron() && !noAuthentication) {
} else if (!req.session.loggedIn && !isElectron && !noAuthentication) {
res.redirect("login");
} else {
next();
@@ -24,7 +24,7 @@ function checkAuth(req: Request, res: Response, next: NextFunction) {
// for electron things which need network stuff
// currently, we're doing that for file upload because handling form data seems to be difficult
function checkApiAuthOrElectron(req: Request, res: Response, next: NextFunction) {
if (!req.session.loggedIn && !isElectron() && !noAuthentication) {
if (!req.session.loggedIn && !isElectron && !noAuthentication) {
reject(req, res, "Logged in session not found");
} else {
next();
@@ -48,7 +48,7 @@ function checkAppInitialized(req: Request, res: Response, next: NextFunction) {
}
function checkPasswordSet(req: Request, res: Response, next: NextFunction) {
if (!isElectron() && !passwordService.isPasswordSet()) {
if (!isElectron && !passwordService.isPasswordSet()) {
res.redirect("set-password");
} else {
next();
@@ -56,7 +56,7 @@ function checkPasswordSet(req: Request, res: Response, next: NextFunction) {
}
function checkPasswordNotSet(req: Request, res: Response, next: NextFunction) {
if (!isElectron() && passwordService.isPasswordSet()) {
if (!isElectron && passwordService.isPasswordSet()) {
res.redirect("login");
} else {
next();