Example #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;
            // vvvvv CUSTOM LANDING PAGE CHANGES vvvvv
            bool IncludeNPCCharacters = false;

            Session["MemberEmailAddress"] = Login.Email;
            Session["SecurityRole"]       = Login.SecurityRoleID;
            txtName.Text         = Login.FirstName + " " + Login.LastName;
            txtLastLocation.Text = Login.LastLoggedInLocation;
            txtLastCampaign.Text = Session["CustomCampaignID"].ToString();
            Login.LoadCharacterForCampaignLandingPage(Login.MemberID, txtLastCampaign.Text.ToInt32(), 1, IncludeNPCCharacters);
            txtLastCharacter.Text = Login.CharacterID.ToString();
            // ^^^^^ CUSTOM LANDING PAGE CHANGES ^^^^^
            txtUserID.Text           = Login.MemberID.ToString();
            intUserID                = Login.MemberID;
            NumberOfCampaigns        = Login.NumberOfCampaigns;
            Session["LoginName"]     = Login.FirstName;
            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;
            }
            Session["CampaignID"] = txtLastCampaign.Text;    // Unique campaign's landing page.  Set last campaign to that campaign so they land there
            // 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 = "MemberDemographics.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());
        }