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