summaryrefslogtreecommitdiff
path: root/src/sessions.c
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-23 10:08:44 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-23 10:08:44 +0200
commite06248ef69b33d102a57aaa31fffcde3240dad9c (patch)
treed2b82eb5a5e2918336f89e241efdeed8bed5ca95 /src/sessions.c
parent79b27457125dc2e259783359085021eea1d26e3a (diff)
downloadbokf-0.1.68.tar.gz
bokf-0.1.68.zip
user.set_password: change your own password; TUI "Byt lösenord"v0.1.68
Needs the current password (wrong ones rate limited like logins) and a password session, requires at least 10 characters, closes the user's other sessions and is audited without secrets. The TUI main menu gets "Byt lösenord" with masked prompts; ^R keeps working with the new password. Masked prompt buffers are wiped before they are freed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/sessions.c')
-rw-r--r--src/sessions.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sessions.c b/src/sessions.c
index 66ec375..21fc1ae 100644
--- a/src/sessions.c
+++ b/src/sessions.c
@@ -74,6 +74,23 @@ void sessions_destroy(const char *id)
}
}
+int sessions_destroy_user(int64_t user_id, const char *keep_id)
+{
+ int n = 0;
+ struct session **pp = &g_sessions;
+ while (*pp) {
+ struct session *s = *pp;
+ if (s->user_id == user_id && (!keep_id || strcmp(s->id, keep_id))) {
+ *pp = s->next;
+ free(s);
+ n++;
+ continue;
+ }
+ pp = &s->next;
+ }
+ return n;
+}
+
void sessions_free_all(void)
{
struct session *s = g_sessions;