protected void btnSubmit_Click(object sender, EventArgs e) { if (DBEmployees.getPassword(txtboxUsername.Text) == txtboxPassword.Text) { CookieHandler.setUserPassword(txtboxUsername.Text, txtboxPassword.Text); HttpContext.Current.Response.Redirect("Menu.aspx"); } else { txtboxUsername.Text = ""; txtboxPassword.Text = ""; labelErrorBox.Text = " Username or Password not found"; } }
public static void checkLogin() //if this method were added as follows to the load portion of every page, // then it would redirect if it could not validate // CookieHandler.checkLogin(); { if (getPassword() == DBEmployees.getPassword(getUsername())) //if password in cookie = password from username { //do nothing, aka use page } else { HttpContext.Current.Response.Redirect("login.aspx"); //else redirect to login } }
//returns current user's first + last name public static string getUserFullName() { return(DBEmployees.getFName(CookieHandler.getID()) + " " + DBEmployees.getLName(CookieHandler.getID())); }
//returns current user's ID number public static int getID() { return(DBEmployees.getIDByUsername(getUsername())); }