public void TestFromUser() { var user = new User() { UserId = 3, Username = "******" }; var auth = AuthModel.GetFromUser(user); Assert.Equal(user.Username, auth.Username); }
public async Task <List <AuthModel> > GetAllUsers() { List <User> users = await _repo.GetAllUsers(); List <AuthModel> models = new List <AuthModel>(); users.ForEach(u => { models.Add(AuthModel.GetFromUser(u)); }); return(models); }
public bool UpdateUserData(AuthModel authModel, Dictionary <string, string> userDictionary, out AuthModel newModel, bool isNewUser = true) { System.Console.WriteLine("update logic: dictionary:"); System.Console.WriteLine(userDictionary); System.Console.WriteLine("userDictionary[\"email\"]"); System.Console.WriteLine(userDictionary["email"]); // todo: if we give user more data, assign here User user = authModel.GetMappedUser(); User authUser = _getUpdatedUserFromDictionary(userDictionary); authUser.Firstname = user.Firstname; authUser.Lastname = user.Lastname; authUser.PasswordHash = ""; authUser.PasswordSalt = ""; authUser.Username = authUser.Email; bool success = false; if (isNewUser) { authUser.DateCreated = DateTime.Now; success = _repo.SaveNewUser(authUser, out user); if (success) { newModel = AuthModel.GetFromUser(user); } else { newModel = null; } } else { if (_repo.UpdateUserPrimaryData(authUser, out user)) { newModel = AuthModel.GetFromUser(user); success = true; } else { newModel = null; } } return(success); }
public AuthModel GetCurrentUserData(string sub) { return(AuthModel.GetFromUser(_repo.GetUserDataBySub(sub))); }