Пример #1
0
        public Task <CustomGrantValidationResult> ValidateAsync(string userName, string password, ValidatedTokenRequest request)
        {
            var user = _pmsDbContext.Set <Employee>()
                       .Include(t => t.Password)
                       .Where(t => t.UserCode.Equals(userName) && t.Password.PasswordString.Equals(password))
                       .FirstOrDefault();

            if (user != null)
            {
                return(Task.FromResult(new CustomGrantValidationResult(user.Id.ToString(), "password")));
            }

            return(Task.FromResult(new CustomGrantValidationResult("无效的用户名或密码")));
        }
Пример #2
0
 public async Task <Employee> FindByUsername(string username)
 {
     return(await _pmsDbContext.Set <Employee>()
            .Include(t => t.Password)
            .FirstOrDefaultAsync(t => t.UserCode.Equals(username, StringComparison.OrdinalIgnoreCase)));
 }