Пример #1
0
        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"));
            }
        }
Пример #2
0
        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));
        }
Пример #3
0
        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));
            }
        }
Пример #4
0
        public async Task <IActionResult> AlterarSenha(AlterarSenhaUsuarioViewModel alterarSenha)
        {
            await _service.AlterarSenha(alterarSenha);

            return(Ok());
        }