public async Task <ActionResult> OnPutPassword([FromBody] PasswordInputModel model) { var user = await _userManager.GetUserAsync(HttpContext.User); if (user != null) { IdentityResult changePasswordResult; if (await _userManager.HasPasswordAsync(user)) { changePasswordResult = await _userManager.ChangePasswordAsync(user, model.Current, model.Password); } else { changePasswordResult = await _userManager.AddPasswordAsync(user, model.Password); } if (changePasswordResult.Succeeded) { return(Ok()); } else { return(BadRequest("Password was not set.")); } } else { return(NotFound("User not recognized")); } }
public LogOnModel() { Title = "log_on_title"; EmailInput = new EmailInputModel("Email", "email", true); PasswordInput = new PasswordInputModel("Password", "password", true); }
public string ValidatePasswordInputModel(PasswordInputModel passwordModel) { if (!Regex.IsMatch(passwordModel.Password, passwordPattern)) { return("Password have to be between 8 and 20 characters long and contain lowercase, uppercase and number, possible characters: @#$%^&+=*.-_"); } return(""); }
public ResetPasswordModel() { Title = Localizer.Localize("reset_password_title"); TokenInput = new HiddenInputModel("Token"); EmailInput = new HiddenInputModel("Email"); PasswordInput = new PasswordInputModel("Password", "password", true); ReEnterPasswordInput = new PasswordInputModel("ReEnterNewPassword", "re_enter_password", true); }
public void PasswordInputModel(string name, string labelKey, bool isRequired, string value) { var model = new PasswordInputModel(name, labelKey, isRequired, value); Assert.AreEqual(name, model.Name); Assert.AreEqual(labelKey, model.LabelKey); Assert.AreEqual(isRequired, model.IsRequired); Assert.AreEqual(value, model.Value); }
public ChangePasswordModel() { Title = "user_change_password_title"; UserUidInput = new HiddenInputModel("UserUid"); OldPasswordInput = new PasswordInputModel("OldPassword", "old_password", true); NewPasswordInput = new PasswordInputModel("NewPassword", "password", true); ReEnterNewPasswordInput = new PasswordInputModel("ReEnterNewPassword", "re_enter_new_password", true); }
public string UpdatePasswordRW(PasswordInputModel passwordModel) { string validationResult = _validator.ValidatePasswordInputModel(passwordModel); if (!string.IsNullOrWhiteSpace(validationResult)) { return(validationResult); } return(""); }
public SignUpModel() { Title = "sign_up_title"; EmailInput = new EmailInputModel("Email", "email", true); FirstNameInput = new InputModel("FirstName", "first_name", true); LastNameInput = new InputModel("LastName", "last_name", true); OrganizationNameInput = new LongInputModel("OrganizationName", "organization_name", true); PasswordInput = new PasswordInputModel("Password", "password", true); IsTermsAcceptedInput = new CheckboxInputModel("IsTermsAccepted", "accept_terms", true); }
public UserSettingsViewModel(User user) { User = user; NewUserInfo = new UserInfo(); PasswordInputModel = new PasswordInputModel(); UserInfoTypes = Enum.GetValues(typeof(UserInfoType)) .Cast <UserInfoType>() .ToSelectList(x => x.GetDescription(), x => ((int)x).ToString()); }
public InviteAcceptModel() { Title = "accept_invite_title"; TokenInput = new HiddenInputModel("Token"); EmailInput = new HiddenInputModel("Email"); FirstNameInput = new InputModel("FirstName", "first_name", true); LastNameInput = new InputModel("LastName", "last_name", true); PasswordInput = new PasswordInputModel("Password", "password", true); ReEnterPasswordInput = new PasswordInputModel("ReEnterPassword", "re_enter_password", true); }
public MvcHtmlString Password <TProperty>(Expression <Func <TModel, TProperty> > expression, string placeholder = null, string label = null) { ModelMetadata modelMetadata = ModelMetadata.FromLambdaExpression(expression, Helper.ViewData); PasswordInputModel passwordInputModel = new PasswordInputModel(Helper, modelMetadata, ExpressionHelper.GetExpressionText(expression), label, placeholder); return(Helper.Partial("EditorTemplates/Forms/Input", passwordInputModel)); }
public AdminAcceptInviteModel() { Title = "admin_accept_title"; OrganizationUidInput = new HiddenInputModel("OrganizationUid"); TokenInput = new HiddenInputModel("Token"); EmailInput = new HiddenInputModel("Email"); FirstNameInput = new InputModel("FirstName", "first_name", true); LastNameInput = new InputModel("LastName", "last_name", true); PasswordInput = new PasswordInputModel("Password", "password", true); ReEnterPasswordInput = new PasswordInputModel("ReEnterPassword", "re_enter_password", true); }
public ActionResult UpdatePassword(PasswordInputModel passwordModel) { var message = _wrapper.UpdatePasswordRW(passwordModel); if (string.IsNullOrWhiteSpace(message)) { passwordModel.Password = new PasswordEncryptor().EncryptPassword(passwordModel.Password); _repo.UpdatePassword(_mapper.Map <PasswordDto>(passwordModel)); _logger.Info($"Update password for lead with Id: {passwordModel.Id}"); return(Ok("Successfully updated")); } else { return(BadRequest(message)); } }
public ActionResult ChangePassword(int id, PasswordInputModel passwordInputModel) { if (passwordInputModel.Password != passwordInputModel.PasswordRepeat) { ModelState.AddModelError("passwordInputModel.PasswordRepeat", "Det repiterade lösenordet skiljer sig!"); } if (!ModelState.IsValid) { return(Settings(id)); } var user = _userService.Get(id); user.Password = Encrypter.Encrypt(passwordInputModel.Password); FlashSuccess("Lösenordet har uppdaterats!"); return(RedirectToAction("Settings", new { id })); }
public async Task <IActionResult> ChangePassword([FromBody] PasswordInputModel model, [FromServices] IUserRepository userRepository) { //データの存在チェック var user = await userRepository.GetByIdAsync(CurrentUserInfo.Id); if (user == null) { return(JsonNotFound($"User ID {CurrentUserInfo.Id} is not found.")); } //パスワード変更を許可するのは、ローカルアカウントのユーザのみ if (user.ServiceType != AuthServiceType.Local) { return(JsonBadRequest($"Only local account user can change the password. Your account service type is {user.ServiceType} not Local.")); } string oldHash = Infrastructure.Util.GenerateHash(model.CurrentPassword, user.Name); if (oldHash != user.Password) { return(JsonBadRequest($"Password mismatch. Please input the current correct password.")); } if (string.IsNullOrWhiteSpace(model.NewPassword)) { //新しいパスワードに空文字は許可しない return(JsonBadRequest($"New password is NOT allowed to set empty string.")); } //パスワードをハッシュ化 string hash = Infrastructure.Util.GenerateHash(model.NewPassword, user.Name); //もしパスワードが同じであれば、エラーにする if (oldHash == hash) { return(JsonBadRequest($"Current password and new password are same.")); } user.Password = hash; unitOfWork.Commit(); return(JsonNoContent()); }
public async Task <IActionResult> ChangePassword(PasswordInputModel inputModel) { if (ModelState.IsValid) { User user = await _userManager.GetUserAsync(User); var changePasswordResult = await _userManager.ChangePasswordAsync(user, inputModel.OldPassword, inputModel.Password); if (changePasswordResult.Succeeded) { await _signInManager.RefreshSignInAsync(user); ViewData["Message"] = "Успешно сменихте паролата си!"; } else { ViewData["ЕrrorMessage"] = "Невалидни данни!"; } } return(this.View("ChangePassword")); }
public ActionResult ChangePassword(PasswordInputModel passwordInputModel) { if (passwordInputModel.Password != passwordInputModel.PasswordRepeat) { ModelState.AddModelError("passwordInputModel.PasswordRepeat", "Det repiterade lösenordet skiljer sig!"); } if (!ModelState.IsValid) { return(Settings()); } var existingUser = _userService.Get(User.Id); existingUser.Password = Encrypter.Encrypt(passwordInputModel.Password); _storage.Store(SessionKeys.User, existingUser); FlashSuccess("Lösenordet har uppdaterats!"); return(RedirectToAction("Settings")); }
public SettingsViewModel(User user) { User = user; PasswordInputModel = new PasswordInputModel(); }