╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Login.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
237 defer allocator.free(password); 238 239 const haxy_moment = self.session.haxy_moment orelse { 240 // no DB context (e.g. wasm/web rendering path); treat as unknown. 241 self.session.data.login_failure = .unknown_user; 242 return; 243 }; 244 245 const result = try evt.User.verifyCredentials(evt.AdminDB, evt.admin_repo_opts.hash, haxy_moment, self.session.arena, username, password); 246 switch (result) { 247 .unknown_user => { 248 self.session.data.login_failure = .unknown_user; 249 return; 250 }, 251 .wrong_password => { 252 self.session.data.login_failure = .wrong_password; 253 return; 254 }, 255 .success => |user_id| { 256 // dupe user_id into the arena so the session can hold a stable slice 257 const user_id_stable = try self.session.arena.allocator().dupe(u8, &user_id); 258 self.session.data.user_id = user_id_stable; 259 self.session.data.login_failure = null; 260 261 // adopt the user's persisted prefs 262 try self.session.loadUserPrefs(); 263 264 // wipe the entered credentials so they don't linger if the 265 // user returns to this page after logging out 266 username_input.clear(allocator); 267 password_input.clear(allocator); 268 269 // jump focus back to the users tab — the login button we 270 // just pressed is about to be hidden by the tab-label swap 271 root_focus.setFocus(self.success_redirect_tab_id); 272 }, 273 } 274 } 275 }; 276