protected void btn_login_Click(object sender, EventArgs e)
        {
            //Pick between embedded component and service.
            xmlAuthServ.IauthClient _login = new xmlAuthServ.IauthClient();
            //xmlAuth _login = new xmlAuth();

            CryptionFunctions _crypt = new CryptionFunctions();

            try
            {
                int result = Convert.ToInt32(_login.Login(tb_login_user.Text, _crypt.Encrypt(tb_login_pw.Text, true)));
                if (result == 0)
                {
                    lbl_login_output.Text = "User Name Does Not Exist";
                }
                else if (result == 1)
                {
                    lbl_login_output.Text = "Successful Login";
                }
                else if (result == 2)
                {
                    lbl_login_output.Text = "Password is Invalid";
                }
                else
                {
                    lbl_login_output.Text = "Something Went Wrong. Try Again Please";
                }
            }
            catch
            {
                lbl_login_output.Text = "Something Went Wrong. Try Again Please";
            }
        }
        protected void btn_register_Click(object sender, EventArgs e)
        {
            //Pick to use xmlAuth as embedded or as service.
            xmlAuthServ.IauthClient _registration = new xmlAuthServ.IauthClient();
            //xmlAuth _registration = new xmlAuth();

            CryptionFunctions _crypt = new CryptionFunctions();

            try
            {
                int result =
                    Convert.ToInt32(_registration.Registeration(tb_register_user.Text, "*****@*****.**",
                                                                _crypt.Encrypt(tb_register_pw.Text, true)));
                String encryptedPw = _crypt.Encrypt(tb_register_pw.Text, true);
                if (result == 1)
                {
                    lbl_register_output.Text = String.Format("User {0} was saved with password {1}.", tb_register_user.Text,
                                                             encryptedPw);
                }
                else if (result == 0)
                {
                    lbl_register_output.Text =
                        "That user already exists. There have been lots of test users added so please try a new one";
                }
                else
                {
                    lbl_register_output.Text = "Please try again";
                }
            }
            catch
            {
                lbl_register_output.Text = "Please try again";
            }
        }
Exemple #3
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //xmlAuth login = new xmlAuth();
            //Use xmlAuth as embedded component or as service.
            xmlAuthServ.IauthClient login = new xmlAuthServ.IauthClient();

            HttpCookie myCookies = Request.Cookies["memberLogin"];

            result = Convert.ToInt32(login.Login(txtusername.Text, _crypt.Encrypt(txtpassword.Text, true)));
            switch (result)
            {
            case 0:
            {
                lblUserNameError.Visible = true;
                lblUserNameError.Text    = "User Name Does Not Exist";
                break;
            }

            case 1:
            {
                //If the user doesn't have a cookie on the browser,
                //Create a new cookie for them - done by Beverly Emmons
                if ((myCookies == null) || (myCookies["username"] == ""))
                {
                    HttpCookie newCookie = new HttpCookie("memberLogin");
                    newCookie["username"] = txtusername.Text;
                    newCookie.Expires     = DateTime.Now.AddMonths(6);
                    Response.Cookies.Add(newCookie);
                }

                Session["loggedIn"] = "member";
                //end Beverly's Code

                Response.Redirect("~/member.aspx");
                break;
            }

            case 2:
            {
                lblPasswordError.Visible = true;
                lblPasswordError.Text    = "Invalid Password";
                break;
            }

            case 3:
            {
                //If the user doesn't have a cookie on the browser,
                //Create a new cookie for them - done by Beverly Emmons
                if ((myCookies == null) || (myCookies["username"] == ""))
                {
                    HttpCookie newCookie = new HttpCookie("memberLogin");
                    newCookie["username"] = txtusername.Text;
                    newCookie.Expires     = DateTime.Now.AddMonths(6);
                    Response.Cookies.Add(newCookie);
                }

                Session["loggedIn"] = "staff";
                //end Beverly's Code

                Response.Redirect("~/staff.aspx");
                break;
            }

            default:
            {
                Console.WriteLine("Something Went Wrong");
                break;
            }
            }
        }