//methods /// <summary> /// login a user /// </summary> /// <param name="username">username of the user</param> /// <param name="password">password of the user</param> /// <param name="user">user object that is being returned to start session</param> /// <returns>succes boolean</returns> public static bool Login(string username, string password, out User user) { user = null; int ID; if (GetUserID(username, out ID)) { //ophalen van de usergegevens DataTable dt = Database.RetrieveQuery("SELECT * FROM \"User\" WHERE \"ID\" = " + ID); user = new User(Convert.ToInt32(dt.Rows[0]["ID"]), dt.Rows[0]["Username"].ToString(), dt.Rows[0]["Email"].ToString()); //password validation return PasswordHash.ValidatePassword(password, dt.Rows[0]["PassHash"].ToString()); } else { return false; } }
/// <summary> /// User logout, set mainuser to null /// </summary> public static void LogoutUser() { mainuser = null; }
/// <summary> /// login user /// </summary> /// <param name="username">username of the login user</param> /// <param name="password">password of the login user</param> /// <returns>succes boolean</returns> public static bool LoginUser(string username, string password) { bool succ = User.Login(username, password, out mainuser); MainUser = mainuser; return succ; }