public User(Guid id, string username, string passwordHash, DatabaseModels.UserType type) { Id = id; Username = username; PasswordHash = passwordHash; Type = type; }
public Task <string?> LogIn(string username, string password, DatabaseModels.UserType userType) { return(Task.Run(() => { var user = _userRepository.GetUser(username, ComputeSha256Hash(password)); if (user is null || user.Type != userType) { return null; } byte[] rngBytes = new byte[24]; rngCsp.GetBytes(rngBytes); string sessionId = Convert.ToBase64String(rngBytes); Startup.ActiveSessions.Add(sessionId, user); return sessionId; })); }