/// <summary> /// 验证用户的正确性 /// </summary> /// <param name="account"></param> /// <param name="password"></param> /// <returns></returns> public Task <AccountUser> ValidateAccountUserAsync(string account, string password) { throw new NotImplementedException(); if (string.IsNullOrWhiteSpace(password)) { throw new ArgumentNullException("密码不能为空"); } var accountUser = _accountUserService.GetAccountUserByNickname(account); if (accountUser != null) { bool passwordCorrect = false; //switch (accountUser.PasswordFormat) //{ // case PasswordFormat.Clear: // { // passwordCorrect = password == accountUser.Password; // } // break; // case PasswordFormat.Encrypted: // { // passwordCorrect = _encryptionService.EncryptText(password) == accountUser.Password; // } // break; // case PasswordFormat.Hashed: // { // string saltKey = _encryptionService.CreateSaltKey(5); // passwordCorrect = _encryptionService.CreatePasswordHash(password, saltKey, _customerSettings.HashedPasswordFormat) == accountUser.Password; // } // break; // default: // break; //} if (passwordCorrect) { accountUser.LastLoginDate = DateTime.Now; _accountUserService.UpdateAccountUser(accountUser); return(Task.FromResult(accountUser)); } } return(Task.FromResult <AccountUser>(null));; }