mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
feat: 🎸 fix electron login logic
This commit is contained in:
parent
347c644f23
commit
0741c8546f
@ -7,7 +7,6 @@ import config from "./config.js";
|
|||||||
import passwordService from "./encryption/password.js";
|
import passwordService from "./encryption/password.js";
|
||||||
import totp from "./totp.js";
|
import totp from "./totp.js";
|
||||||
import openID from "./open_id.js";
|
import openID from "./open_id.js";
|
||||||
import openIDEncryption from './encryption/open_id_encryption.js';
|
|
||||||
import options from "./options.js";
|
import options from "./options.js";
|
||||||
import attributes from "./attributes.js";
|
import attributes from "./attributes.js";
|
||||||
import type { NextFunction, Request, Response } from "express";
|
import type { NextFunction, Request, Response } from "express";
|
||||||
@ -21,6 +20,9 @@ function checkAuth(req: Request, res: Response, next: NextFunction) {
|
|||||||
|
|
||||||
if (!sqlInit.isDbInitialized()) {
|
if (!sqlInit.isDbInitialized()) {
|
||||||
res.redirect('setup');
|
res.redirect('setup');
|
||||||
|
} else if (isElectron) {
|
||||||
|
next();
|
||||||
|
return;
|
||||||
} else if (currentTotpStatus !== lastAuthState.totpEnabled || currentSsoStatus !== lastAuthState.ssoEnabled) {
|
} else if (currentTotpStatus !== lastAuthState.totpEnabled || currentSsoStatus !== lastAuthState.ssoEnabled) {
|
||||||
req.session.destroy((err) => {
|
req.session.destroy((err) => {
|
||||||
if (err) console.error('Error destroying session:', err);
|
if (err) console.error('Error destroying session:', err);
|
||||||
@ -34,7 +36,7 @@ function checkAuth(req: Request, res: Response, next: NextFunction) {
|
|||||||
}
|
}
|
||||||
res.redirect('/login');
|
res.redirect('/login');
|
||||||
return;
|
return;
|
||||||
} else if (!req.session.loggedIn && !isElectron && !noAuthentication) {
|
} else if (!req.session.loggedIn && !noAuthentication) {
|
||||||
const redirectToShare = options.getOptionBool("redirectBareDomain");
|
const redirectToShare = options.getOptionBool("redirectBareDomain");
|
||||||
if (redirectToShare) {
|
if (redirectToShare) {
|
||||||
// Check if any note has the #shareRoot label
|
// Check if any note has the #shareRoot label
|
||||||
|
Loading…
x
Reference in New Issue
Block a user