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"; } }
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_encrypt_Click(object sender, EventArgs e) { try { CryptionFunctions _crypt = new CryptionFunctions(); String strToEncrypt = tb_encrypt.Text; String result = _crypt.Encrypt(strToEncrypt, true); lbl_encryptOut.Text = result; } catch { lbl_encryptOut.Text = "Please Try Again."; } }
protected void btnRegistration_Click(object sender, EventArgs e) { int resutlt = Convert.ToInt32(_registration.Registeration(txtusername.Text, txtemail.Text, _crypt.Encrypt(txtpassword.Text, true))); if (resutlt == 1) { //Create new cookie for the new member - done by Beverly Emmons HttpCookie newCookie = new HttpCookie("memberLogin"); newCookie["username"] = txtusername.Text; newCookie.Expires = DateTime.Now.AddMonths(6); Response.Cookies.Add(newCookie); //end Beverly's code Response.Redirect("~/login.aspx"); } else { lblUserNameError.Visible = true; lblUserNameError.Text = "User Name Aleardy Exist"; } Response.Write(resutlt); }
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; } } }
protected void Button1_Click(object sender, EventArgs e) { int resutlt = Convert.ToInt32(_registration.RegisterationStaff(TextBox1.Text, TextBox3.Text, _crypt.Encrypt(TextBox2.Text, true))); if (resutlt == 1) { //Create new cookie for the new member - done by Beverly Emmons HttpCookie newCookie = new HttpCookie("memberLogin"); newCookie["username"] = TextBox1.Text; newCookie.Expires = DateTime.Now.AddMonths(6); Response.Cookies.Add(newCookie); //end Beverly's code Response.Redirect("~/login.aspx"); } else { Label1.Visible = true; Label1.Text = "User Name Aleardy Exist"; } Response.Write(resutlt); }