Exemplo n.º 1
0
 protected override void OnLoadComplete(EventArgs e)
 {
     base.OnLoadComplete(e);
     if (!Page.IsPostBack)
     {
         if (SessionProxy.Instance().GetValue("USER.AUTHENTICATED") != null)
         {
             Response.Redirect("/Login");
         }
     }
 }
Exemplo n.º 2
0
 protected override void OnLoadComplete(EventArgs e)
 {
     base.OnLoadComplete(e);
     if (!Page.IsPostBack)
     {
         if (SessionProxy.Instance().HasKey("USER.AUTHENTICATED"))
         {
             Response.Redirect("/Login");
         }
         Logger.Instance().Log(Debug.Instance(), new LogDebug("A debug text"));
     }
 }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //get the database version
            try
            {
                string DBVersionString = DBVersion.GetDBVersion;

                if (new MaintenanceMode().IsMaintenanceModeEnabled() == APIResponse.OK)
                {
                    if (Page.TemplateControl.AppRelativeVirtualPath != "~/Login.aspx")
                    {
                        CookieProxy.Instance().SetValue("LoginMessage", new SettingsFromDB().FetchSettingsFromDB(new Settings("LOGIN_MAINTENANCE_MESSAGE")).GetSettingsValue(), DateTime.Now.AddDays(2));
                        Response.Redirect("/signout.aspx?r=/Login", false);
                    }
                }

                // here t is the token (if the user has logged in once from this browser)
                UserProfile UserProfileObj = new UserProfile();
                if (CookieProxy.Instance().HasKey("t"))
                {
                    UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
                    bool response = new Security(UserProfileObj).AuthenticateUser();
                    if (response == true)
                    {
                        loginLabel.Visible    = false;
                        registerLabel.Visible = false;
                        userProfile.Visible   = true;
                        UserTemplate <IUserProfile> Template = new NormalUserTemplate();
                        userName.Text = Template.FetchParticularProfile(UserProfileObj).GetFirstName();
                    }
                    else
                    {
                        // remove the cookie
                        CookieProxy.Instance().RemoveKey("t");
                        loginLabel.Visible    = true;
                        registerLabel.Visible = true;
                        userProfile.Visible   = false;
                    }
                    SessionProxy.Instance().SetValue("USER.AUTHENTICATED", response, DateTime.Now);
                }
                // load the menu
                LoadMasterMenu();
            }
            catch (Exception ex)
            {
                Logger.Instance().Log(Fatal.Instance(), ex);
                Response.Redirect("~/ErrorPages/Error.aspx?e=500", true);
            }
        }
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string LoginMessage = "";

        try
        {
            if (CookieProxy.Instance().HasKey("LoginMessage"))
            {
                LoginMessage = CookieProxy.Instance().GetValue("LoginMessage").ToString();
            }
            // remove the session
            SessionProxy.Instance().RemoveKey("USER.AUTHENTICATED");

            // remove the cookies
            CookieProxy.Instance().RemoveKey("t");
            CookieProxy.Instance().RemoveKey("um");

            // redirect to login
            if (Request.QueryString["r"] != null)
            {
                // set the redirect cookie
                CookieProxy.Instance().SetValue("InternalRedirect", Request.QueryString["r"], DateTime.Now.AddSeconds(10));
                Response.Redirect("/InternalRedirect");
            }
            UserProfile UserProfileObj = new UserProfile();
            if (CookieProxy.Instance().HasKey("t"))
            {
                UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
                new Security(UserProfileObj).RemoveTokenFromDB();
            }
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Warn.Instance(), ex);
        }
        finally
        {
            if (LoginMessage != "")
            {
                CookieProxy.Instance().SetValue("LoginMessage", LoginMessage, DateTime.Now.AddDays(2));
            }
        }
        Response.Redirect("/login");
    }
Exemplo n.º 5
0
    protected override void OnLoadComplete(EventArgs e)
    {
        base.OnLoadComplete(e);
        if (!Page.IsPostBack)
        {
            if (SessionProxy.Instance().HasKey("USER.AUTHENTICATED"))
            {
                if (CookieProxy.Instance().HasKey("t"))
                {
                    if ((bool)SessionProxy.Instance().GetValue("USER.AUTHENTICATED") == true)
                    {
                        // check if there is any redirect on querystring
                        if (Request.QueryString["r"] != null)
                        {
                            SessionProxy.Instance().SetValue("InternalRedirect", Request.QueryString["r"], DateTime.Now.AddSeconds(10));
                            Response.Redirect("/InternalRedirect");
                        }
                        Response.Redirect("/Products");
                    }
                }
                else
                {
                    Response.Redirect("/Signout");
                }
            }
        }

        // check if there is any loginmessage cookie
        if (CookieProxy.Instance().HasKey("LoginMessage"))
        {
            LoginMessage.InnerText = CookieProxy.Instance().GetValue("LoginMessage").ToString();
            LoginMessage.Visible   = true;

            // remove this key
            CookieProxy.Instance().RemoveKey("LoginMessage");
        }
    }