public void EditUser(UserViewModel ApplicationUserView) { ApplicationUser ApplicationUser = new ApplicationUser() { Id = ApplicationUserView.ID, UserName = ApplicationUserView.UserName, Email = ApplicationUserView.Email, PasswordHash = ApplicationUserView.HashedPassword, SecurityStamp = ApplicationUserView.Salt, Active = ApplicationUserView.Active }; //ApplicationUser OldApplicationUserData = UserRepository.GetByID(ApplicationUser.Id); //ApplicationUser.SecurityStamp = OldApplicationUserData.SecurityStamp; //string NewHassedPassword = EncryptionService.EncryptPassword(ApplicationUser.PasswordHash, ApplicationUser.SecurityStamp); ////check if password has been changed //if (OldApplicationUserData.PasswordHash != NewHassedPassword) //{ // string salt = EncryptionService.CreateSalt(); // string HassedPassword = EncryptionService.EncryptPassword(ApplicationUser.PasswordHash, salt); // ApplicationUser.PasswordHash = HassedPassword; // ApplicationUser.SecurityStamp = salt; //} ////ApplicationUser.Role = null; ////ApplicationUser.Tasks = null; UserRepository.Edit(ApplicationUser.Id, ApplicationUser); SaveUser(); }
/// <summary> /// Verifies the token with the one in the database /// </summary> /// <param name="username"></param> /// <param name="token"></param> /// <returns></returns> public bool Verify(string username, string token) { ApplicationUser user = _repository.Get(filter => filter.UserName == username).FirstOrDefault(); //get user from db if (user != null) { //get token from db string dbUserToken = user.UserName; //verander dit naar token if (token == dbUserToken) { //user.VerifiedEmail = true; //remove token _repository.Edit(user); _uow.Commit(); return(true); } else { return(false); } } else { return(false); } }
//Saved de veranderingen in de tabel: Applicationuser public void Save(Models.ApplicationUser user) { if (user == null) { throw new ArgumentException("user"); } if (UserExists(user.Email, user.UserID)) { throw new ArgumentException("username exists"); } if (user.UserID == 0) { _repository.Add(user); } else { _repository.Edit(user); } _uow.Commit(); }