// 登入 public bool Login(string account, string password) { Member user = Validator.IsValidEmail(account) ? db.Members.Where(member => member.Email == account).FirstOrDefault() : db.Members.Where(member => member.MemberID == account).FirstOrDefault(); if (user == null) { return(false); } long salt = TimeConverter.ToTimestamp(user.CreateAt); if (!ChoyPassword.Validate(password, salt, user.Psw)) { return(false); } ChoySession session = ChoySession.Current; session.LoginId = user.MemberID; session.LoginAt = TimeConverter.ToTimestamp(DateTime.Now); session.PerCode = user.PerCode; return(true); }
// 登出 public void Logout() { ChoySession.Clear(); // 清除 session }