Пример #1
0
        protected void MemberLogin(string AttemptedUsername, string AttemptedPassword)
        {
            Classes.cLogin Login         = new Classes.cLogin();
            string         PasswordToUse = txtPassword.Text;

            if (PasswordToUse == "")
            {
                PasswordToUse = AttemptedPassword;
            }
            Login.Load(txtUserName.Text, PasswordToUse);
            int    intUserID;
            int    NumberOfCampaigns = 0;
            string WhereAreYouGoing;

            Session["MemberEmailAddress"] = Login.Email;
            Session["SecurityRole"]       = Login.SecurityRoleID;
            txtName.Text             = Login.FirstName + " " + Login.LastName;
            txtLastLocation.Text     = Login.LastLoggedInLocation;
            txtLastCharacter.Text    = Login.LastLoggedInCharacter.ToString();
            txtLastCampaign.Text     = Login.LastLoggedInCampaign.ToString();
            txtUserID.Text           = Login.MemberID.ToString();
            intUserID                = Login.MemberID;
            NumberOfCampaigns        = Login.NumberOfCampaigns;
            Session["LoginName"]     = Login.FirstName;
            Session["UserFullName"]  = Login.FirstName + " " + Login.LastName;
            Session["Username"]      = Session["AttemptedUsername"];
            Session["LoginPassword"] = Session["AttemptedPassword"];
            Session["UserID"]        = Login.MemberID;
            if (txtLastCharacter.Text != "0")
            {
                Session["SelectedCharacter"] = txtLastCharacter.Text;
            }
            if (txtLastCampaign.Text != "0")
            {
                Session["CampaignID"] = txtLastCampaign.Text;
            }
            // Write login entry to UserLoginAudit table
            string txtIPAddress      = "";
            string txtBrowser        = "";
            string txtBrowserVersion = "";
            string txtPlatform       = "";
            string txtOSVersion      = "";

            if (Session["IPAddress"] != null)
            {
                txtIPAddress = Session["IPAddress"].ToString();
            }
            if (Session["Browser"] != null)
            {
                txtBrowser = Session["Browser"].ToString();
            }
            if (Session["BrowserVersion"] != null)
            {
                txtBrowserVersion = Session["BrowserVersion"].ToString();
            }
            if (Session["Platform"] != null)
            {
                txtPlatform = Session["Platform"].ToString();
            }
            if (Session["OSVersion"] != null)
            {
                txtOSVersion = Session["OSVersion"].ToString();
            }
            Login.LoginAudit(Login.MemberID, txtUserName.Text, txtPassword.Text, txtIPAddress, txtBrowser, txtBrowserVersion, txtPlatform, txtOSVersion);
            Session["WebPage"] = Login.LastLoggedInLocation;
            Session["LastLoggedInLocation"] = Login.LastLoggedInLocation;
            // If no campaigns on My Campaign list (i.e. no CMCampaignPlayers records for UserID) send them to campaign pick page
            if (NumberOfCampaigns < 1)
            {
                Response.Redirect("~/Index1.aspx");
            }
            // Go to the default or last page visited
            if (Session["WebPage"] == null)
            {
                Session["WebPage"] = "~/General/MemberHome.aspx";
            }
            else
            {
                if (txtLastLocation.Text == "")
                {
                    txtLastLocation.Text = "Profile/Demographics.aspx";
                }
                string FirstChar      = txtLastLocation.Text.Substring(1, 1);
                int    LocationLength = txtLastLocation.Text.Length;
                if (FirstChar == "/")
                {
                    LocationLength       = LocationLength - 1;
                    txtLastLocation.Text = txtLastLocation.Text.Substring(2, LocationLength);
                }
                Session["WebPage"] = "~/" + txtLastLocation.Text;
            }
            WhereAreYouGoing = Session["WebPage"].ToString();
            Response.Redirect(Session["WebPage"].ToString());
        }
Пример #2
0
        /// <summary>
        /// The person has already been verified so figure out where to go and save the assorted variables.
        /// </summary>
        /// <param name="Login">The login class that has already been loaded and validated.</param>
        protected void MemberLogin(Classes.cLogin Login)
        {
            string sLoginPassword = tbPassword.Text;

            if ((string.IsNullOrEmpty(sLoginPassword)) &&
                (Session["SavePassword"] != null))
            {
                if (!string.IsNullOrEmpty(Session["SavePassword"].ToString()))
                {
                    sLoginPassword = Session["SavePassword"].ToString();
                }
            }

            Session.Clear();

            int NumberOfCampaigns = 0;

            Session["MemberEmailAddress"] = Login.Email;
            Session["SecurityRole"]       = Login.SecurityRoleID;
            NumberOfCampaigns             = Login.NumberOfCampaigns;

            Session["LoginName"]     = Login.FirstName;
            Session["UserName"]      = Login.Username;
            Session["UserFullName"]  = Login.FirstName + " " + Login.LastName;
            Session["LoginPassword"] = Login.Password;
            Session["UserID"]        = Login.MemberID;
            Session.Remove("SuperUser");
            if (Login.SuperUser)
            {
                Session["SuperUser"] = 1;
            }

            // Get OS and browser settings and save them to session variables
            HttpBrowserCapabilities bc = HttpContext.Current.Request.Browser;
            string UserAgent           = HttpContext.Current.Request.UserAgent;

            Session["IPAddress"]      = HttpContext.Current.Request.UserHostAddress;
            Session["Browser"]        = bc.Browser;
            Session["BrowserVersion"] = bc.Version;
            Session["Platform"]       = bc.Platform;
            Session["OSVersion"]      = Request.UserAgent;

            // Login the user and get the last logged in location so we can go there.
            Login.LoginAudit(Login.MemberID, tbUserName.Text, sLoginPassword, HttpContext.Current.Request.UserHostAddress, bc.Browser, bc.Version, bc.Platform, Request.UserAgent);

            if (NumberOfCampaigns < 1)
            {
                Response.Redirect("NewUserSelectCampaign.aspx", true);
            }
            else
            {
                string sPageGoingTo = "Default.aspx";

                //  Disable the last logged in location because it was causing issues.
                //if (!String.IsNullOrEmpty(Login.LastLoggedInLocation))
                //{
                //	sPageGoingTo = Login.LastLoggedInLocation;
                //	if (sPageGoingTo.StartsWith("/"))
                //		sPageGoingTo = sPageGoingTo.Substring(1);
                //}

                //// If the page doesn't exist, go to the default page.
                //if (!File.Exists(Server.MapPath(sPageGoingTo)))
                //	sPageGoingTo = "Default.aspx";

                Response.Redirect(sPageGoingTo, true);
            }
        }