aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/loader.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-04-13 18:49:40 +0200
committerbptato <nincsnevem662@gmail.com>2025-04-13 19:10:41 +0200
commit3e549ffad05b4250ffc9b6e2203fbd30094bb8e9 (patch)
treecea80ef1a5a024dd4055fef7f76518a719f7bfa0 /src/server/loader.nim
parente07ab87d94cbc701c55b64e1a2b1c60ac7297233 (diff)
downloadchawan-3e549ffad05b4250ffc9b6e2203fbd30094bb8e9.tar.gz
loader, pager: fix login with username only
It's a bit tricky, because "username only" means "try with the username only" only if no password has been recorded for the username on the origin.
Diffstat (limited to 'src/server/loader.nim')
-rw-r--r--src/server/loader.nim9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/server/loader.nim b/src/server/loader.nim
index 38435d27..8ffcb19e 100644
--- a/src/server/loader.nim
+++ b/src/server/loader.nim
@@ -1641,8 +1641,13 @@ proc addAuth(ctx: var LoaderContext; stream: SocketStream;
let origin = url.authOrigin
let item = ctx.authMap.findItem(origin)
if item != nil:
- item.username = url.username
- item.password = url.password
+ # Only replace the old item if the URL sets a password or the old
+ # item's username is different.
+ # This way, loading a URL with only the username set still lets us
+ # load the password which is already associated with said username.
+ if url.password != "" or item.username != url.username:
+ item.username = url.username
+ item.password = url.password
else:
let item = AuthItem(
origin: url.authOrigin,