mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
feature complete; tested and working on local linux machine
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import OptionsWidget from "../options_widget.js";
|
||||
import options from "../../../../services/options.js";
|
||||
import { t } from "../../../../services/i18n.js";
|
||||
import type { OptionMap, OptionNames } from "../../../../../../services/options_interface.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="card-body">
|
||||
@@ -27,9 +28,12 @@ export default class ShareSettingsOptions extends OptionsWidget {
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
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',
|
||||
options.redirectBareDomain === 'true');
|
||||
|
||||
@@ -39,9 +43,9 @@ export default class ShareSettingsOptions extends OptionsWidget {
|
||||
|
||||
async save() {
|
||||
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');
|
||||
await this.updateOption('showLoginInShareTheme', showLoginInShareTheme.toString());
|
||||
await this.updateOption<'showLoginInShareTheme'>('showLoginInShareTheme', showLoginInShareTheme.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,9 @@ const ALLOWED_OPTIONS = new Set([
|
||||
"textNoteEditorMultilineToolbar",
|
||||
"layoutOrientation",
|
||||
"backgroundEffects",
|
||||
"allowedHtmlTags" // Allow configuring HTML import tags
|
||||
"allowedHtmlTags",
|
||||
"redirectBareDomain",
|
||||
"showLoginInShareTheme"
|
||||
]);
|
||||
|
||||
function getOptions() {
|
||||
|
||||
@@ -7,6 +7,7 @@ import { isElectron } from "./utils.js";
|
||||
import passwordEncryptionService from "./encryption/password_encryption.js";
|
||||
import config from "./config.js";
|
||||
import passwordService from "./encryption/password.js";
|
||||
import options from "./options.js";
|
||||
import type { NextFunction, Request, Response } from "express";
|
||||
|
||||
const noAuthentication = config.General && config.General.noAuthentication === true;
|
||||
@@ -15,7 +16,8 @@ function checkAuth(req: Request, res: Response, next: NextFunction) {
|
||||
if (!sqlInit.isDbInitialized()) {
|
||||
res.redirect("setup");
|
||||
} else if (!req.session.loggedIn && !isElectron && !noAuthentication) {
|
||||
res.redirect("share");
|
||||
const redirectToShare = options.getOption('redirectBareDomain') === 'true';
|
||||
res.redirect(redirectToShare ? "share" : "login");
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user