Beispiel #1
0
        public async Task <ActionResult> Index(LoginModel model)
        {
            try
            {
                var            usuario    = model.NombreLogin;
                var            contrasena = model.Contrasena;
                RequestLoginBE ObjLogin   = new RequestLoginBE()
                {
                    DNI      = usuario,
                    Password = contrasena
                };
                var autenticar = await UsuarioPCL.Login(ObjLogin);

                if (autenticar.Code != 200)
                {
                    throw new Exception(autenticar.Message);
                }

                var sesion = new BaseModel();
                sesion.Usuario = autenticar.Data.response;

                Session[Sesiones.UsuarioLogin] = sesion;
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
        }
Beispiel #2
0
        public Result AutenticarLogin(RequestLoginBE ObjRequestLoginBE)
        {
            try
            {
                var data = objUsuarioDA.Usuario_Autenticar(ObjRequestLoginBE);
                if (data == null)
                {
                    throw new CustomException("Credenciales del usuario son incorrectos. Revisar usuario y contraseña");
                }

                result.Data = data;
            }
            catch (SqlException sqlex)
            {
                result.Code    = Notification.OperationCode.ErrorDataBase.GetHashCode();;
                result.Message = sqlex.Message;
            }
            catch (CustomException cusex)
            {
                result.Code    = Notification.OperationCode.ErrorCustom.GetHashCode();;
                result.Message = cusex.Message;
            }
            catch (Exception ex)
            {
                result.Code    = Notification.OperationCode.ErrorNotControl.GetHashCode();;
                result.Message = "Usuario o contraseña incorrecto.";
            }
            return(result);
        }
Beispiel #3
0
        public int NotificaUsuario(RequestLoginBE objLoginBE)
        {
            var ObjResult = (from a in model.User
                             where a.Email.Equals(objLoginBE.Email)
                             select a).Single();
            MailMessage m  = new MailMessage();
            SmtpClient  sc = new SmtpClient();

            m.From = new MailAddress("*****@*****.**");
            m.To.Add(objLoginBE.Email);
            m.Subject = "Notificación de Recuperacion de Contraseña";
            m.Body    = "<html><head><meta charset='UTF-8'></head><body><table width='600' cellspacing='0' cellpadding='0' border='0'  align='center' style='background-color: #f7f7f7;'><tbody><tr><td align='center' height='8' style='border-bottom: 1px solid #9494" +
                        "94; background - color:#a00d0d;border-top:medium none #716f63;padding:5px;'><span style='font-family:tahoma;color: #ffffff;padding:5px 0 5px 5px ;'>ACM RESTORE</span></td></tr><tr><td align='center' style='border-width: 1px; border-style: solid;   border-co" +
                        "lor: #dbdbdb #e7e7e7 #e7e7e7; background-color: white; padding-left: 10px;'><img src='http://sealcheckchip.com/Content/Imagenes/descarga.png' width='150' height='100' /><span style='font-family: tahoma; color: #6f6f6f; font-size: 12px;'></span></td></tr><tr><td height='11'  style='padding:5px;background-color: #e8e8e8;'>Estimado " + ObjResult.Name + ",<br /> Usted ha solicitado que se recuerde la contraseña de la web www.sealcheckchip.com <br />Su contraseña es " + Base64Decode(ObjResult.Password) + "<br />Atentamente, <br />El equipo de Draesger Perú SAC</td></tr><tr><td height='20' align='center' style='background-color: #a00d0d; font-family:" +
                        "tahoma; color: white; font - size: 10px; border - top: 1px solid #595959;padding:5px;'>Draeger Perú SAC - GESTIÓN DE SALUD OCUPACIONAL </td></tr></tbody></table></body></html>";
            m.IsBodyHtml      = true;
            sc.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            sc.Host           = "mail.sealcheckchip.com";
            string str1 = "gmail.com";
            string str2 = "*****@*****.**".ToLower();

            if (str2.Contains(str1))
            {
                try
                {
                    sc.Port        = 587;
                    sc.Credentials = new System.Net.NetworkCredential("*****@*****.**", "italo1511+");
                    sc.EnableSsl   = true;
                    sc.Send(m);
                }
                catch (Exception ex)
                {
                    return(2);
                }
            }
            else
            {
                try
                {
                    sc.Port        = 25;
                    sc.Credentials = new System.Net.NetworkCredential("*****@*****.**", "italo1511+");
                    sc.EnableSsl   = false;
                    sc.Send(m);
                }
                catch (Exception ex)
                {
                    return(2);
                }
            }
            return(1);
        }
Beispiel #4
0
        public static async Task <ResultDTO <int> > NotificaLogin(RequestLoginBE requestLoginBE)
        {
            try
            {
                string post   = url + "NotificaUsuario";
                var    result = await ResultPCL <int> .Post(post, requestLoginBE);

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #5
0
        public static async Task <ResultDTO <Response> > Login(RequestLoginBE requestLoginBE)
        {
            try
            {
                string post   = url + "AutenticarUsuario";
                var    result = await ResultPCL <Response> .Post(post, requestLoginBE);

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #6
0
        public Response Usuario_Autenticar(RequestLoginBE ObjRequestBE)
        {
            try
            {
                String EncripPass = Base64Encode(ObjRequestBE.Password);
                var    ObjMenu    = from a in model.Menu
                                    where a.Activo.Equals(true)
                                    select new MenuBE.ResponseMenuBE()
                {
                    IdMenu = a.TypeUser,
                    Nombre = a.Menu1,
                    Icono  = a.Icono,
                    URL    = a.URL,
                };

                var query = from p in model.UserType
                            select new PerfilBE()
                {
                    IdPerfil = p.ID,
                    Nombre   = p.UserType1
                };
                var             login     = model.Sp_LoginUsuer(ObjRequestBE.DNI, EncripPass).Single();
                ResponseLoginBE ObjResult = new ResponseLoginBE {
                    IdUsuario     = login.IdUsuario,
                    DNI           = login.DNI,
                    Name          = login.Name,
                    LastName1     = login.LastName1,
                    LastName2     = login.LastName2,
                    Type          = login.Type,
                    Password      = login.Password,
                    Mobile        = login.Mobile,
                    Email         = login.Email,
                    RegisterDate  = login.RegisterDate,
                    perfilList    = query.ToList(),
                    LastAccesDate = Convert.ToDateTime(login.LastAccesDate)
                };
                ObjResult.menuList = ObjMenu.ToList();
                Response Result = new Response()
                {
                    response = ObjResult
                };
                return(Result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #7
0
        public async Task <ActionResult> Password(LoginModel model)
        {
            try
            {
                RequestLoginBE ObjLogin = new RequestLoginBE()
                {
                    Email = model.Correo
                };
                var notificar = await UsuarioPCL.NotificaLogin(ObjLogin);

                if (notificar.Code != 200)
                {
                    throw new Exception(notificar.Message);
                }
                ViewBag.Notifica = notificar.Data;
                return(View(model));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
        }
Beispiel #8
0
 public Result NotificaUsuario(RequestLoginBE objLoginBE)
 {
     try
     {
         var data = objUsuarioDA.NotificaUsuario(objLoginBE);
         result.Data = data;
     }
     catch (SqlException sqlex)
     {
         result.Code    = Notification.OperationCode.ErrorDataBase.GetHashCode();;
         result.Message = sqlex.Message;
     }
     catch (CustomException cusex)
     {
         result.Code    = Notification.OperationCode.ErrorCustom.GetHashCode();;
         result.Message = cusex.Message;
     }
     catch (Exception ex)
     {
         result.Code    = Notification.OperationCode.ErrorNotControl.GetHashCode();;
         result.Message = ex.Message;
     }
     return(result);
 }
Beispiel #9
0
 public IHttpActionResult NotificaUsuario(RequestLoginBE objLoginBE)
 {
     return(Ok(objUsarioBL.NotificaUsuario(objLoginBE)));
 }
Beispiel #10
0
 public IHttpActionResult AutenticarUsuario(RequestLoginBE objLoginBE)
 {
     return(Ok(objUsarioBL.AutenticarLogin(objLoginBE)));
 }