Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LoginUsuario_Authenticate(object sender, AuthenticateEventArgs e)
        {
            try
            {
                Session.Abandon();
                LoginUser.UserName = LoginUser.UserName.Trim().ToLower();
                DTSeguridad objDTSeguridad = new DTSeguridad
                {
                    Usuario =
                    {
                        Nombre = LoginUser.UserName.Trim().ToLower(),
                        Password = BLEncriptacion.Encrypt(LoginUser.Password.Trim())
                    }
                };

                BLSeguridad objSeguridadBL = new BLSeguridad(objDTSeguridad);
                objSeguridadBL.ValidarUsuario();

                if (objDTSeguridad.Usuario.UsuarioValido)
                {
                    e.Authenticated = true;
                    FormsAuthentication.SignOut();
                    FormsAuthentication.Initialize();
                    FormsAuthentication.SetAuthCookie(LoginUser.UserName.Trim().ToLower(), false);
                    ObjSessionDataUI.ObjDTUsuario = objDTSeguridad.Usuario;
                    UIUtilidades.EliminarArchivosSession(Session.SessionID);

                    if (ObjSessionDataUI.ObjDTUsuario.EsUsuarioInicial)
                        Response.Redirect("~/Private/Account/ChangePassword.aspx", false);
                    else
                        //if (Request.Params["ReturnUrl"] != null)
                        FormsAuthentication.RedirectFromLoginPage(LoginUser.UserName.Trim(), false);
                }
                else
                {
                    e.Authenticated = false;
                    LoginUser.FailureText = UIConstantesGenerales.MensajeLoginFallido;
                }
            }
            catch (Exception ex)
            {
                Master.ManageExceptions(ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LoginUsuario_Authenticate(object sender, AuthenticateEventArgs e)
        {
            try
            {
                Session.Abandon();
                DTSeguridad objDTSeguridad = new DTSeguridad
                {
                    Usuario =
                    {
                        Nombre = LoginUser.UserName.Trim(),
                        Password = LoginUser.Password.Trim()
                    }
                };

                BLSeguridad objSeguridadBL = new BLSeguridad(objDTSeguridad);
                objSeguridadBL.ValidarUsuario();

                if (objDTSeguridad.Usuario.UsuarioValido)
                {
                    e.Authenticated = true;
                    FormsAuthentication.SignOut();
                    FormsAuthentication.Initialize();
                    FormsAuthentication.SetAuthCookie(LoginUser.UserName.Trim(), false);
                    ObjSessionDataUI.ObjDTUsuario = objDTSeguridad.Usuario;
                    UIUtilidades.EliminarArchivosSession(Session.SessionID);
                    if (ObjSessionDataUI.ObjDTUsuario.EsUsuarioInicial)
                        Response.Redirect("~/Private/Account/ChangePassword.aspx", false);
                }
                else
                {
                    e.Authenticated = false;
                    LoginUser.FailureText = UIConstantesGenerales.MensajeLoginFallido;
                }
            }
            catch (Exception ex)
            {
                try
                {
                    ManageExceptions(ex);
                    updVentaneMensajes.Update();
                }
                catch
                {

                }
            }
        }