public LoginController(ref int userAcctType, string user, string pass) { fail = false; Database_Manager dbMngr = new Database_Manager(); if (dbMngr.checkUsername(user)) { //checks the db password against the salted version of the provided password string dbPass = dbMngr.FetchPassword(user); string saltPass = (pass + ".cs.is.fun.team.dirk."); string hashPass = Convert.ToString(saltPass.GetHashCode()); if (dbPass != (hashPass)) { MessageBox.Show("Your password was not correct. Please enter the right credentials.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); fail = true; } else { //Check user's account type string type = dbMngr.Fetchaccttype(user); Console.WriteLine(type); if (type == "Administrator") { userAcctType = 3; } else if (type == "Researcher") { userAcctType = 2; } else if (type == "Student") { userAcctType = 1; } //Proceed to Main Menu //new MainMenu(userAcctType).Show(); } } else { MessageBox.Show("Your username was not correct. Please enter the right credentials.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); fail = true; } }
public bool verify(string username, string password, string first, string last, string acct) { Database_Manager db = new Database_Manager(); if (password != "" && password != null) { string salted = Salt(password); int temp = Hash(salted); salted = temp.ToString(); if (db.FetchPassword(username) != password) { return(false); } } if (first != "" && first != null) { if (db.Fetchfirst(username) != first) { return(false); } } if (last != "" && last != null) { if (db.FetchLast(username) != last) { return(false); } } if (acct != "(No change)") { if (db.Fetchaccttype(username) != acct) { return(false); } } return(true); }