Beispiel #1
0
 /// <summary>
 /// When the button is clicked, this code uses the CustomerLogin class to validate the entered user name and password. If they are valid, it redirects to Default2.aspx. If they are invalid, it will display an invalid login message.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Button1_Click(object sender, EventArgs e)
 {
     CustomerLogin cl = new CustomerLogin();
     int pk = cl.Login(txtuser.Text, txtpassword.Text);
     if (pk != 0)
     {
         Session["person"] = pk;
         Response.Redirect("Default2.aspx");
     }
     else
     {
         lblmsg.Text = "Invalid Login";
     }
 }
Beispiel #2
0
        public IHttpActionResult UserLogin([FromBody] LoginModelRequest loginRequest)
        {
            LoginModelResponse loginResponse = new LoginModelResponse();

            try
            {
                if (!ModelState.IsValid)
                {
                    loginResponse.Error = new Error {
                        Code = ErrorCodes.ModelStateInvalid, Message = "Please correct the errors"
                    };
                    return(Ok(loginResponse));
                }
                loginResponse = CustomerLogin.Login(loginRequest);
                return(Ok(loginResponse));
            }
            catch (Exception ex)
            {
                return(Ok(ex.Message));
            }
        }
Beispiel #3
0
    protected void LogInBtn_Click(object sender, EventArgs e)
    {
        //This code uses the CustomerLogin class to validate the entered log in information, retrieve the Person Key of the user who logged in, and save the key in the "person" session, then redirect to Default5.aspx
        try
        {
            CustomerLogin cl = new CustomerLogin();
            int pk = cl.Login(txtuser.Text, txtpassword.Text);
            if (pk != 0)
            {
                Session["person"] = pk;
                Response.Redirect("Default5.aspx", false);
            }
            else
            {
                lblmsg.Text = "Invalid Login";
            }
           }

        catch (Exception ex)
        {
            Session["error"] = ex.Message;
            Response.Redirect("Default6.aspx");
        }
    }