/// <summary> /// Login with input information /// </summary> /// <param name="thisPage"></param> /// <param name="UserName"></param> /// <param name="Password"></param> /// <param name="Remember"></param> /// <returns></returns> public static int LogIn(string UserName, string Password, bool Remember) { ORM.User loginUser = new VL.ORM.User("UserName", UserName); //Check if user is exist or not. Return 1 if not if (loginUser.UserID == 0) { return 1; } //Check if the password is correct, if not, return 2 if (loginUser.Password != Password) { return 2; } //Ok, now store the logged user into our main current.user User = loginUser; //Check to store the user in cookie if (Remember) { RememberUser = loginUser; } return 0; }
/// <summary> /// Log user out and clear the cookie /// </summary> /// <param name="thisPage"></param> public static void LogOut() { User = null; RememberUser = null; }
/// <summary> /// Load the user from the cookie. Return null if couldn't find the user /// </summary> /// <param name="thisPage"></param> /// <returns></returns> public static ORM.User LoadCookieUser() { User = RememberUser; return User; }