/// <summary> /// Changes user password /// </summary> /// <param name="id">User Id</param> /// <param name="currentPassword">CurrentPassword</param> /// <param name="newPassword">Newpassword</param> /// <param name="remarks">List of erros</param> /// <returns>If the operation succeded</returns> public async Task <bool> ChangePassword(Guid id, string currentPassword, string newPassword, Dictionary <string, string> remarks) { var userModel = await _UserDb.GetSingle(id); if (userModel == null || !ValidatePassword(userModel, currentPassword)) { remarks.Add("UserDoesntExistsOrInvalidPws", "User doesn't exists or the password is invalid"); return(false); } var now = DateTime.Now; UserPasswordHistory userPassword = new UserPasswordHistory { Id = Guid.NewGuid(), InitialDate = now, Password = EncriptionHelper.EncriptPassword(newPassword, now) }; if (userModel.PasswordHistory == null) { userModel.PasswordHistory = new List <UserPasswordHistory> { userPassword } } ; else { userModel.PasswordHistory.Add(userPassword); } return(await _UserDb.Update(userModel)); }