Ejemplo n.º 1
0
        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            DataTiers.passwordHash ph = new DataTiers.passwordHash(txtPassword.Text);

            DataTiers.userTier ut   = new DataTiers.userTier();
            DataModels.Users   user = new DataModels.Users();
            user.email    = txtUserName.Text;
            user.username = txtUserName.Text;



            try
            {
                Tuple <string, string> temp = ut.login(user);
                if (ph.Verify(temp.Item1, temp.Item2, txtPassword.Text))
                {
                    user            = ut.getInfo(user);
                    Session["User"] = user;
                    Session["ID"]   = user.userID;
                    Response.Redirect("MyAccount.aspx");
                }
                else
                {
                    Label1.Text = "Incorrect password or email";
                }
            }
            catch (Exception ex)
            {
                Label1.Text = "Incorrect password or email";
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
        protected void btnSumbit_Click(object sender, EventArgs e)
        {
            DataTiers.passwordHash ph = new DataTiers.passwordHash(txtPassword.Text);

            DataTiers.userTier ut   = new DataTiers.userTier();
            DataModels.Users   user = new DataModels.Users();
            user.email    = txtEmail.Text;
            user.username = txtUsername.Text;
            user.salt     = ph.Salt;
            user.hash     = ph.Hash;
            user.major    = txtMajor.Text;


            try
            {
                if (ut.userExist(user) == false)
                {
                    ut.insertUser(user);
                    Response.Redirect("Success.aspx");
                }
                else
                {
                    // lblError.Text = "<strong>Warning: </strong>The username or email already exists";
                    CustomValidator1.ErrorMessage = "<strong>Warning: </strong>The username or email already exists";
                    CustomValidator1.IsValid      = false;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }