Skip to content

Build your personal knowledge base with Trilium Notes

fix: 🐛 init error with totp

Jinea7fbb154fc6
diff --git a/src/services/auth.ts b/src/services/auth.ts
index 99ca8b42f5..a01df03076 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 624a845ede..250db687b2 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 eab308d6e4..1fa0404abe 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 8b64d01199..14967a6d67 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 },