mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-11-03 14:41:38 +08:00
feature complete; tested and working on local linux machine
This commit is contained in:
parent
bc66e98533
commit
ed8b8e50a4
@ -1,6 +1,7 @@
|
|||||||
import OptionsWidget from "../options_widget.js";
|
import OptionsWidget from "../options_widget.js";
|
||||||
import options from "../../../../services/options.js";
|
import options from "../../../../services/options.js";
|
||||||
import { t } from "../../../../services/i18n.js";
|
import { t } from "../../../../services/i18n.js";
|
||||||
|
import type { OptionMap, OptionNames } from "../../../../../../services/options_interface.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -27,9 +28,12 @@ export default class ShareSettingsOptions extends OptionsWidget {
|
|||||||
doRender() {
|
doRender() {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
this.contentSized();
|
this.contentSized();
|
||||||
|
|
||||||
|
// Add change handlers for both checkboxes
|
||||||
|
this.$widget.find('input[type="checkbox"]').on('change', () => this.save());
|
||||||
}
|
}
|
||||||
|
|
||||||
async optionsLoaded(options: Record<string, any>) {
|
async optionsLoaded(options: OptionMap) {
|
||||||
this.$widget.find('input[name="redirectBareDomain"]').prop('checked',
|
this.$widget.find('input[name="redirectBareDomain"]').prop('checked',
|
||||||
options.redirectBareDomain === 'true');
|
options.redirectBareDomain === 'true');
|
||||||
|
|
||||||
@ -39,9 +43,9 @@ export default class ShareSettingsOptions extends OptionsWidget {
|
|||||||
|
|
||||||
async save() {
|
async save() {
|
||||||
const redirectBareDomain = this.$widget.find('input[name="redirectBareDomain"]').prop('checked');
|
const redirectBareDomain = this.$widget.find('input[name="redirectBareDomain"]').prop('checked');
|
||||||
await this.updateOption('redirectBareDomain', redirectBareDomain.toString());
|
await this.updateOption<'redirectBareDomain'>('redirectBareDomain', redirectBareDomain.toString());
|
||||||
|
|
||||||
const showLoginInShareTheme = this.$widget.find('input[name="showLoginInShareTheme"]').prop('checked');
|
const showLoginInShareTheme = this.$widget.find('input[name="showLoginInShareTheme"]').prop('checked');
|
||||||
await this.updateOption('showLoginInShareTheme', showLoginInShareTheme.toString());
|
await this.updateOption<'showLoginInShareTheme'>('showLoginInShareTheme', showLoginInShareTheme.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,7 +72,9 @@ const ALLOWED_OPTIONS = new Set([
|
|||||||
"textNoteEditorMultilineToolbar",
|
"textNoteEditorMultilineToolbar",
|
||||||
"layoutOrientation",
|
"layoutOrientation",
|
||||||
"backgroundEffects",
|
"backgroundEffects",
|
||||||
"allowedHtmlTags" // Allow configuring HTML import tags
|
"allowedHtmlTags",
|
||||||
|
"redirectBareDomain",
|
||||||
|
"showLoginInShareTheme"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function getOptions() {
|
function getOptions() {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import { isElectron } from "./utils.js";
|
|||||||
import passwordEncryptionService from "./encryption/password_encryption.js";
|
import passwordEncryptionService from "./encryption/password_encryption.js";
|
||||||
import config from "./config.js";
|
import config from "./config.js";
|
||||||
import passwordService from "./encryption/password.js";
|
import passwordService from "./encryption/password.js";
|
||||||
|
import options from "./options.js";
|
||||||
import type { NextFunction, Request, Response } from "express";
|
import type { NextFunction, Request, Response } from "express";
|
||||||
|
|
||||||
const noAuthentication = config.General && config.General.noAuthentication === true;
|
const noAuthentication = config.General && config.General.noAuthentication === true;
|
||||||
@ -15,7 +16,8 @@ function checkAuth(req: Request, res: Response, next: NextFunction) {
|
|||||||
if (!sqlInit.isDbInitialized()) {
|
if (!sqlInit.isDbInitialized()) {
|
||||||
res.redirect("setup");
|
res.redirect("setup");
|
||||||
} else if (!req.session.loggedIn && !isElectron && !noAuthentication) {
|
} else if (!req.session.loggedIn && !isElectron && !noAuthentication) {
|
||||||
res.redirect("share");
|
const redirectToShare = options.getOption('redirectBareDomain') === 'true';
|
||||||
|
res.redirect(redirectToShare ? "share" : "login");
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user