Exemple #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        // Session["UserId"] = "4f37fdd8745cb305e42cd7a0";
        bool isValidUserName = LoginBLL.IsValidUserName(txtUserName.Text);

        if (isValidUserName)
        {
            bool isValidPassword = LoginBLL.IsValidPassword(txtPassword.Text);

            if (isValidPassword)
            {
                bool isValid = LoginBLL.IsValidLogin(txtUserName.Text, txtPassword.Text);
                if (isValid)
                {
                    Session["UserEmail"] = txtUserName.Text;

                    string Email = Session["UserEmail"].ToString();

                    Session["UserId"] = UserBLL.BLL_UserId(Email);



                    Response.Redirect("UI/User/UserData.aspx");    //the page to be opened on successful login
                }
            }
            else //password not valid but username valid
            {
                //Login1.PasswordRequiredErrorMessage = "oye pass";
                // ValidationSummary1.HeaderText = "oye pass";
                Session["LoginAttempt"] = "1";
                Response.Redirect("UI/Login/ReenterPassword.aspx?UserName=" + txtUserName.Text);
            }
        }
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        Session["LoginAttempt"] = Convert.ToInt32(Session["LoginAttempt"]) + 1;
        if (LoginBLL.IsValidLogin(lblUserName.Text, txtPassword.Text))
        {
            Session["UserId"] = UserBLL.BLL_UserId(lblUserName.Text); // user email
            Response.Redirect("../User/UserData.aspx");               //the page to be opened on successful login
        }

        else //password not valid but username valid
        {
            if (Convert.ToInt32(Session["LoginAttempt"]) > 2)
            {
                Response.Redirect("IncorrectPassword.aspx?UserName="******"ReenterPassword.aspx?UserName=" + lblUserName.Text);
            }
        }
    }