Esempio n. 1
0
        public IHttpActionResult ResetarSenha([FromBody] DTOContato contato)
        {
            try
            {
                SenhaRecuperacaoService recuperacaoService = new SenhaRecuperacaoService();
                EmailNotification       emailNotifier      = new EmailNotification(MimeKit.Text.TextFormat.Html);

                recuperacaoService.RecuperSenha(contato, emailNotifier, Domain.Enum.TipoContato.EMAIL);

                return(Ok(new {
                    message = "Senha resetada com sucesso, verifique sua caixa de e-mail.",
                    data = new List <string>(),
                    success = true
                }));
            }
            catch (Exception ex)
            {
                return(Ok(new
                {
                    message = $"Oops, não foi possível resetar sua senha pelo seguinte motivo: {ex.Message}",
                    data = new List <string>(),
                    success = false
                }));
            }
        }
Esempio n. 2
0
        public IHttpActionResult RecuperarSenha([FromBody] DTOContato contato)
        {
            try
            {
                SenhaRecuperacaoService service = new SenhaRecuperacaoService();

                EmailNotification emailNotifier = new EmailNotification(MimeKit.Text.TextFormat.Html);

                string url = $@"{Url.Content("~/")}/Home/AlterarSenha";
                //Url.Action("RecuperarSenha", "Home", null, protocol: Request.Url.Scheme);

                service.RecuperarSenhaGerarToken(contato, emailNotifier, url);

                return(Json(new
                {
                    success = true,
                    message = $"E-mail de reset de senha enviado para {contato.Contato}",
                    data = new List <string>()
                }));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    message = ex.Message,
                    data = new List <string>()
                }));
            }
        }
        public ActionResult AlterarSenha(string token)
        {
            SenhaAcesso usuario = null;

            SenhaRecuperacaoService recuperacaoService = new SenhaRecuperacaoService();

            if (!string.IsNullOrEmpty(token) && recuperacaoService.RecuperarSenhaValidarToken(token, out usuario))
            {
                FormsAuthentication.SetAuthCookie(usuario.Usuario, true);
            }
            else if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login"));
            }

            return(View());
        }