protected void SignIn_Click(object sender, EventArgs e)
        {
            string username = TextBoxUserName.Value;
            string password = TextBoxPassword.Value;

            if (Auth.VerifyUsernamePassword(username, password))
            {
                //VERIFICATION TRUE CASE
                //Update session data, redirect
                DataSetTableAdapters.UsersTableAdapter usertableadapter = new DataSetTableAdapters.UsersTableAdapter();
                Session["LoggedIn"] = true;
                Session["UserInfo"] = usertableadapter.GetUserByUsernameIgnoreActive(username)[0];
                //screenTableadApter.GetScreensByCinemaId(1, true);
                System.Diagnostics.Debug.WriteLine("Login passed");

                if (Request["redirect"] != null)
                {
                    Response.Redirect(Request["redirect"].ToString());
                }
                else
                {
                    Response.Redirect("/");
                }
            }
            else
            {
                //VERIFICATION FALSE CASE
                System.Diagnostics.Debug.WriteLine("Login failed");
                if (Request["redirect"] != null)
                {
                    Response.Redirect("/LogIn.aspx?alert=2&redirect=" + Request["redirect"].ToString());
                }
                Response.Redirect("/LogIn.aspx?alert=2");
            }
        }
Exemple #2
0
        protected void textBoxRegister_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("REGISTER CLICKED");
            string ADDR1     = textBoxALine1.Text;
            string ADDR2     = textBoxALine2.Text;
            string CITY      = textBoxACity.Text;
            string REGION    = textBoxARegion.Text;
            string COUNTRY   = textBoxACountry.Text;
            string POSTCODE  = textBoxAPost.Text;
            string USERNAME  = textBoxUsername.Text;
            string PASSWORD  = textBoxPassword.Text;
            string PASSWORD2 = inputPasswordConfirm.Text;
            string EMAIL     = textBoxEmail.Text;
            string PHONENO   = textBoxPhonNo.Text;
            string FIRSTNAME = textBoxFirstN.Text;
            string LASTNAME  = textBoxLastN.Text;

            //Validate


            //is the username taken
            int MINLENGTH_FIRSTNAME = 2;
            int MINLENGTH_LASTNAME  = 2;
            int MINLENGTH_EMAIL     = 6;
            int MINLENGTH_USERNAME  = 3;
            int MINLENGTH_PASSWORD  = 6;
            int MINLENGTH_PHONE     = 6;
            int MINLENGTH_PCODE     = 3;
            int MINLENGTH_LINE1     = 2;
            int MINLENGTH_LINE2     = 0;
            int MINLENGTH_REGION    = 3;
            int MINLENGTH_COUNTRY   = 4;

            if (FIRSTNAME.Length < MINLENGTH_FIRSTNAME ||
                LASTNAME.Length < MINLENGTH_LASTNAME ||
                EMAIL.Length < MINLENGTH_EMAIL ||
                USERNAME.Length < MINLENGTH_USERNAME ||
                PASSWORD.Length < MINLENGTH_PASSWORD ||
                PHONENO.Length < MINLENGTH_PHONE ||
                POSTCODE.Length < MINLENGTH_PCODE ||
                ADDR1.Length < MINLENGTH_LINE1 ||
                ADDR2.Length < MINLENGTH_LINE2 ||
                REGION.Length < MINLENGTH_REGION ||
                COUNTRY.Length < MINLENGTH_COUNTRY)
            {
                validateError(6);
            }

            DataSetTableAdapters.UsersTableAdapter usertableadapter = new DataSetTableAdapters.UsersTableAdapter();
            DataSet.UsersDataTable data = usertableadapter.GetUserByUsernameIgnoreActive(USERNAME);
            if (data.Count != 0)
            {
                validateError(7);
            }
            else
            {
                checkMail(EMAIL);
                checkPass(PASSWORD, PASSWORD2);

                if (PHONENO.Length < 8 || PHONENO.Length > 15)
                {
                    validateError(5);
                }
                //Register
                Register_User(ADDR1, ADDR2, CITY, REGION, COUNTRY, POSTCODE, USERNAME, PASSWORD, EMAIL, PHONENO, FIRSTNAME, LASTNAME);
            }
        }