public ActionResult PasswordRetrieval(RestartPassword restart) { if (ModelState.IsValid) { var model = database.Users.Find(restart.UserName); if (model == null) { ModelState.AddModelError("", "UserName không tồn tại"); } else { var findPer = database.Person.Find(model.PersonID); if (findPer.Email == restart.Email) { var newPass = new Share().RandomText(); if (SendPass(findPer.PersonID, newPass)) { UpdateUser(findPer.PersonID, newPass); } else { ModelState.AddModelError("", "Lỗi gửi Email"); } } else { ModelState.AddModelError("", "Email không chính xác!"); } } } return(View("PasswordRetrieval")); }
public ActionResult Reset(RestartPassword RpModel) { var user = _clienteService.GetCorreo(RpModel.Email); if (user != null) { if (user.codigo.Equals(RpModel.Code)) { if (_clienteService.changePassword(user, RpModel.ConfirmPassword)) { _clienteService.insertCodigo(user, ""); return(Ok()); } } return(NoContent()); } return(BadRequest()); }