admin/options: keep_session_alive #219

Massimo Melina committed Apr 19, 2023 at 17:46 UTC c991bc7637dc2fa0d74d8f7733c909afa7c2f734
3 files changed +10 -5
admin/src/OptionsPage.ts
+4 -3
@@ -145,11 +145,12 @@ export default function OptionsPage() {
145 helperText: "Leave empty to never delete" },
146 { k: 'min_available_mb', comp: NumberField, md: 3, min : 0, unit: "MBytes", placeholder: "None",
147 label: "Min. available disk space", helperText: "Reject uploads that don't comply" },
148 - { k: 'admin_net', comp: NetmaskField, label: "Admin-panel accessible from", placeholder: "any address",
149 - helperText: h(Fragment, {}, "IP address of browser machine. ", h(WildcardsSupported))
150 - },
148 + { k: 'keep_session_alive', comp: BoolField, helperText: "Keeps you logged in while the page is left open and the computer is on" },
149 { k: 'zip_calculate_size_for_seconds', comp: NumberField, label: "Calculate ZIP size for", unit: "seconds",
150 helperText: "If time is not enough, the browser will not show download percentage" },
151 + { k: 'admin_net', comp: NetmaskField, label: "Admin-panel accessible from", placeholder: "any address", md: 12,
152 + helperText: h(Fragment, {}, "IP address of browser machine. ", h(WildcardsSupported))
153 + },
154 { k: 'mime', comp: StringStringField,
155 keyLabel: "Files", keyWidth: 7,
156 valueLabel: "Mime type", valueWidth: 4
config.md
+2 -1
@@ -39,7 +39,8 @@ This file contains details the configuration files.
39 - `title` text displayed in the tab of your browser. Default is "File server".
40 - `file_menu_on_link` if to display file-menu when clicking on link, or have a dedicated button instead. Default is true.
41 - `min_available_mb` refuse to accept uploads if available disk space is below this threshold. Default is 100.
42 -- `dont_overwrite_uploading` uploading a file with name already present in the folder will be renamed if this is enabled. Default is false.
42 +- `dont_overwrite_uploading` uploading a file with name already present in the folder will be renamed if this is enabled. Default is false.
43 +- `keep_session_alive` keeps you logged in while the page is left open and the computer is on. Default is true.
44
45 #### Virtual File System (VFS)
46
src/api.auth.ts
+4 -1
@@ -19,9 +19,11 @@ import Koa from 'koa'
19 import { changeSrpHelper, changePasswordHelper } from './api.helpers'
20 import { ctxAdminAccess } from './adminApis'
21 import { prepareState } from './middlewares'
22 +import { defineConfig } from './config'
23
24 const srp6aNimbusRoutines = new SRPRoutines(new SRPParameters())
25 const ongoingLogins:Record<string,SRPServerSessionStep1> = {} // store data that doesn't fit session object
26 +const keepSessionAlive = defineConfig('keep_session_alive', true)
27
28 // centralized log-in state
29 async function loggedIn(ctx:Koa.Context, username: string | false) {
@@ -40,7 +42,8 @@ async function loggedIn(ctx:Koa.Context, username: string | false) {
42 }
43
44 function makeExp() {
43 - return { exp: new Date(Date.now() + SESSION_DURATION) }
45 + return !keepSessionAlive.get() ? undefined
46 + : { exp: new Date(Date.now() + SESSION_DURATION) }
47 }
48
49 export const login: ApiHandler = async ({ username, password }, ctx) => {