public ActionResult RedefinirSenha(RedefirSenhaViewModel redefirSenhaViewModel) { if (_usuarioAppService.ObterPorId(redefirSenhaViewModel.UsuarioId).PrimeiroAcesso == true) { if (!ModelState.IsValid) { ViewBag.UsuarioId = redefirSenhaViewModel.UsuarioId; return(View(redefirSenhaViewModel)); } if (redefirSenhaViewModel.Senha != redefirSenhaViewModel.ConfirmarSenha) { ViewBag.UsuarioId = redefirSenhaViewModel.UsuarioId; ModelState.AddModelError("Erro", "As senhas não conferem!"); return(View(redefirSenhaViewModel)); } _usuarioAppService.AlterarSenha(redefirSenhaViewModel.UsuarioId, redefirSenhaViewModel.Senha); _usuarioAppService.AlterarPrimeiroAcesso(redefirSenhaViewModel.UsuarioId); return(View("Index")); } else { return(Content("Senha já alterada")); } }
public JsonResult AlterarSenha(Guid usuarioId, string novaSenha) { var usuario = _usuarioAppService.AlterarSenha(usuarioId, novaSenha); if (usuario.ValidationResult.IsValid) { return(Json(new { validationResult = usuario.ValidationResult }, JsonRequestBehavior.AllowGet)); } return(Json(new { validationResult = usuario.ValidationResult }, JsonRequestBehavior.AllowGet)); }
public ActionResult AlterarSenha(string senhaAtual, string novaSenha, string confirmaNovaSenha) { try { _usuarioService.AlterarSenha(senhaAtual, novaSenha, confirmaNovaSenha); ViewBag.Sucesso = true; var usuarioDTO = _usuarioService.FindUsuario(ControladorDeSessao.GetUsuario().Id); return(View(usuarioDTO)); } catch (Exception ex) { TratamentoErro.Tratamento(this, ex); var usuarioDTO = _usuarioService.FindUsuario(ControladorDeSessao.GetUsuario().Id); return(View(usuarioDTO)); } }
public async Task <IActionResult> AlterarSenha(AlterarSenhaUsuarioViewModel alterarSenha) { await _service.AlterarSenha(alterarSenha); return(Ok()); }