╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ UserLogin.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
206 switch (result) { 207 .unknown_user => { 208 try self.rememberFailure(.unknown_user, username); 209 return; 210 }, 211 .wrong_password => { 212 try self.rememberFailure(.wrong_password, username); 213 return; 214 }, 215 .success => |user_id| { 216 // dupe user_id into the arena so the session can hold a stable slice 217 const user_id_stable = try self.session.arena.allocator().dupe(u8, &user_id); 218 self.session.data.user_id = user_id_stable; 219 try self.session.rememberSshKey(); 220 221 // adopt the user's name and persisted prefs 222 try self.session.loadUser(); 223 224 // wipe the entered credentials so they don't linger if the 225 // user returns to this page after logging out 226 username_input.clear(allocator); 227 password_input.clear(allocator); 228 229 // leave the user tab for the page it belongs to, where the 230 // web's /login redirect also lands 231 try self.session.navigate(self.session.data.current_page.pageRoot()); 232 }, 233 } 234 } 235 236 fn rememberFailure(self: *View, failure: ui.Session.FormFeedback.LoginFailure, username: []const u8) !void { 237 self.session.data.form_feedback = .{ .login = .{ 238 .failure = failure, 239 .username = try self.session.arena.allocator().dupe(u8, username), 240 } }; 241 } 242 }; 243