@samitouri / QOSami-HFS / commits / f25839ac

basic-web: show current username

Massimo Melina committed Jun 10, 2024 at 23:45 UTC f25839ac58f8f0909f16cdb93d9c878d8ce08afa
1 file changed +4 -3
src/basicWeb.ts
+4 -3
@@ -22,9 +22,9 @@ export function basicWeb(ctx: Koa.Context, node: VfsNode) {
22 return true
23 }
24 if (get === 'logout') {
25 - ctx.body = `<script>location = '?'</script>`
25 + ctx.body = `<script>setTimeout(() => location = '?', 1000)</script>`
26 setLoggedIn(ctx, false)
27 - ctx.status = HTTP_UNAUTHORIZED
27 + ctx.status = HTTP_UNAUTHORIZED // not effective on firefox30
28 return true
29 }
30 const forced = get === 'basic'
@@ -40,7 +40,8 @@ export function basicWeb(ctx: Koa.Context, node: VfsNode) {
40 ctx.body = stream
41 stream.push(`<title>${title.get()}</title><body>`)
42 stream.push(getSection('basicHeader'))
43 - const links: Dict<string> = getCurrentUsername(ctx) ? { '?get=logout': "Logout" } : { '?get=login': "Login" }
43 + const u = getCurrentUsername(ctx)
44 + const links: Dict<string> = u ? { '?get=logout': `Logout (${u})` } : { '?get=login': "Login" }
45 stream.push(_.map(links, (v,k) => a(k, v)).join(' ') + '\n<ul>\n')
46 if (ctx.state.originalPath.length > 1)
47 stream.push('<li>' + a('..' + force, '..') + '\n')