Beispiel #1
0
        public ActionResult EnviarCorreoRecuperacion(string email)
        {
            int respuesta = 0;//0 => correo no existe, 1 => error al enviar correo, 2 => correo enviado

            try
            {
                bool correoExistente = new BRecuperarPassword().CorreoExistente(email);
                if (correoExistente)
                {
                    string token = tokenNumber();
                    if (token != "")
                    {
                        EToken nuevoToken = new EToken
                        {
                            NumberToken = token,
                            CreateDate  = DateTime.Now,
                            ExpireDate  = DateTime.Now.AddMinutes(5),
                            Email       = email,
                            Status      = true
                        };
                        long IdToken = new BRecuperarPassword().CrearToken(nuevoToken);
                        if (IdToken > 0)
                        {
                            long resultado = sendMail(nuevoToken);
                            if (resultado > 0) //email enviado
                            {
                                respuesta = 2; //enviado
                            }
                            else
                            {
                                resultado = 1;
                            }
                        }
                    }
                }
                else
                {
                    respuesta = 0;//no existe
                }
            }
            catch (GettingException ex)
            {
                StackTrace st    = new StackTrace(ex, true);
                StackFrame frame = st.GetFrame(0);
                throw new GettingException(string.Format("{0}", "Error: " + ex.Message.ToString() + " Origen: " + ex.TargetSite.ReflectedType.FullName.ToString() + " Metodo: " + frame.GetMethod().Name.ToString() + " Linea: " + frame.GetFileLineNumber().ToString()));
            }
            return(Json(respuesta));
        }
Beispiel #2
0
        public ActionResult CambiarPassword(string tokenNumber, string passwordChange)
        {
            string        emailDesencriptado = string.Empty;
            ManagerCookie cookie             = new ManagerCookie();
            ClientCookie  coookieSession     = cookie.ObtenerCookie(HttpContext.Request.Cookies["userAuth"]);
            string        emailEncriptado    = string.IsNullOrEmpty(coookieSession.userName) ? string.Empty : coookieSession.userName.ToString();

            if (!emailEncriptado.IsEmpty())
            {
                Seguridad seguridad = new Seguridad();
                emailDesencriptado = seguridad.desencriptar(emailEncriptado);
            }
            long respuesta = new BRecuperarPassword().CambiarPassword(emailDesencriptado, tokenNumber, passwordChange);

            return(Json(respuesta));
        }