╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ User.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
10 11 pub fn consume( 12 comptime DB: type, 13 comptime hash_kind: hash.HashKind, 14 haxy_moment: DB.HashMap(.read_write), 15 event_id: *const [evt.event_id_size]u8, 16 event_maybe: ?@This(), 17 ) !void { 18 const user_key = hash.hashInt(hash_kind, event_id); 19 20 const event_id_to_user_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "event-id->user")); 21 const event_id_to_user = try DB.HashMap(.read_write).init(event_id_to_user_cursor); 22 23 if (event_maybe) |event| { 24 const user_cursor = try event_id_to_user.putCursor(user_key); 25 const user = try DB.HashMap(.read_write).init(user_cursor); 26 try evt.upsert(@This(), DB, hash_kind, user, event); 27 } else { 28 if (!try event_id_to_user.remove(user_key)) return error.EventNotFound; 29 30 const user_id_to_repos_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "user-id->repos")); 31 const user_id_to_repos = try DB.HashMap(.read_write).init(user_id_to_repos_cursor); 32 _ = try user_id_to_repos.remove(user_key); 33 } 34 } 35 36 pub const password_hash_max_len = bcrypt.hash_length * 2; 37 38 pub fn hashPassword( 39 password: []const u8, 40 out: []u8, 41 io: std.Io, 42 ) ![]const u8 { 43 return bcrypt.strHash(password, .{ 44 .params = bcrypt.Params.owasp, 45 .encoding = .phc, 46 }, out, io); 47 } 48