From ea7fbb154fc6014647fdc7b71dc42008c6691e96 Mon Sep 17 00:00:00 2001 From: Jin <22962980+JYC333@users.noreply.github.com> Date: Fri, 28 Mar 2025 02:37:12 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20init=20error=20with=20tot?= =?UTF-8?q?p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/auth.ts | 8 +++++--- src/services/encryption/data_encryption.ts | 2 -- src/services/encryption/my_scrypt.ts | 2 -- src/services/options_init.ts | 6 +++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/services/auth.ts b/src/services/auth.ts index 99ca8b42f..a01df0307 100644 --- a/src/services/auth.ts +++ b/src/services/auth.ts @@ -14,13 +14,15 @@ import type { NextFunction, Request, Response } from "express"; const noAuthentication = config.General && config.General.noAuthentication === true; function checkAuth(req: Request, res: Response, next: NextFunction) { + if (!sqlInit.isDbInitialized()) { + res.redirect('setup'); + } + const currentTotpStatus = totp.isTotpEnabled(); const currentSsoStatus = openID.isOpenIDEnabled(); const lastAuthState = req.session.lastAuthState || { totpEnabled: false, ssoEnabled: false }; - if (!sqlInit.isDbInitialized()) { - res.redirect('setup'); - } else if (isElectron) { + if (isElectron) { next(); return; } else if (currentTotpStatus !== lastAuthState.totpEnabled || currentSsoStatus !== lastAuthState.ssoEnabled) { diff --git a/src/services/encryption/data_encryption.ts b/src/services/encryption/data_encryption.ts index 624a845ed..250db687b 100644 --- a/src/services/encryption/data_encryption.ts +++ b/src/services/encryption/data_encryption.ts @@ -1,5 +1,3 @@ -"use strict"; - import crypto from "crypto"; import log from "../log.js"; diff --git a/src/services/encryption/my_scrypt.ts b/src/services/encryption/my_scrypt.ts index eab308d6e..1fa0404ab 100644 --- a/src/services/encryption/my_scrypt.ts +++ b/src/services/encryption/my_scrypt.ts @@ -1,5 +1,3 @@ -"use strict"; - import optionService from "../options.js"; import crypto from "crypto"; import sql from "../sql.js"; diff --git a/src/services/options_init.ts b/src/services/options_init.ts index 8b64d0119..14967a6d6 100644 --- a/src/services/options_init.ts +++ b/src/services/options_init.ts @@ -132,9 +132,9 @@ const defaultOptions: DefaultOption[] = [ { name: "promotedAttributesOpenInRibbon", value: "true", isSynced: true }, { name: "editedNotesOpenInRibbon", value: "true", isSynced: true }, { name: "mfaEnabled", value: "false", isSynced: false }, - { name: 'mfaMethod', value: 'totp', isSynced: false }, - { name: 'encryptedRecoveryCodes', value: 'false', isSynced: true }, - { name: 'userSubjectIdentifierSaved', value: 'false', isSynced: true }, + { name: "mfaMethod", value: "totp", isSynced: false }, + { name: "encryptedRecoveryCodes", value: "false", isSynced: false }, + { name: "userSubjectIdentifierSaved", value: "false", isSynced: false }, // Appearance { name: "splitEditorOrientation", value: "horizontal", isSynced: true },