示例#1
0
        /// <summary>
        /// Login check
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string email    = txtEmail.Text;
            string password = txtPassword.Text;

            if (email == "" || password == "")
            {
                // TODO: Error message
                return;
            }
            else
            {
                // Get the user from the email he/she wants to login with
                User user = UserSQL.getUserFromEmail(email);

                bool allowedLogin = allowLogin(user.Password, password);

                if (allowedLogin)
                {
                    // Set user related settings
                    Common.setUser(user);

                    // Redirect to the products page
                    Response.Redirect("products.aspx", true);
                }
                else
                {
                    MessageBox.Show(allowedLogin.ToString());
                }
            }
        }