Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feature complete; tested and working on local linux machine
matt wilkieed8b8e50a427
diff --git a/src/public/app/widgets/type_widgets/options/other/share_settings.ts b/src/public/app/widgets/type_widgets/options/other/share_settings.tsindex d908409488..d7743c63cc 100644--- a/src/public/app/widgets/type_widgets/options/other/share_settings.ts+++ b/src/public/app/widgets/type_widgets/options/other/share_settings.ts@@ -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());}}diff --git a/src/routes/api/options.ts b/src/routes/api/options.tsindex 14cb7ec425..85272ea627 100644--- a/src/routes/api/options.ts+++ b/src/routes/api/options.ts@@ -72,7 +72,9 @@ const ALLOWED_OPTIONS = new Set(["textNoteEditorMultilineToolbar","layoutOrientation","backgroundEffects",- "allowedHtmlTags" // Allow configuring HTML import tags+ "allowedHtmlTags",+ "redirectBareDomain",+ "showLoginInShareTheme"]);function getOptions() {diff --git a/src/services/auth.ts b/src/services/auth.tsindex d89fad6335..5ba56e426f 100644--- a/src/services/auth.ts+++ b/src/services/auth.ts@@ -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();}