private async Task ValidateOfficeUserAsync(ResourceOwnerPasswordValidationContext context) { try { var exists = await _officeUserRepository.ExisteAsync(context.UserName, context.Password); if (!exists) { context.Result = BuildInvalidGrantValidationResult(); return; } var user = await _officeUserRepository.BuscarPorUsernameAsync(context.UserName); context.Result = new GrantValidationResult( subject: user.Codigo.ToString(), authenticationMethod: "custom", claims: user.Permissoes.AsSecurityClaims() ); } catch (Exception ex) { _logger.LogError(ex, ex.Message); context.Result = BuildInvalidGrantValidationResult(); } }
public async Task <UsuarioEscritorio> BuscarPorUsernameAsync(string username) { return(await _officeUserRepository.BuscarPorUsernameAsync(username)); }