public ApplicationServiceBehavior(
            IServiceContextAccessor context,
            IApplicationRepositoryFactory repositoryFactory,
            ApplicationVersions versions,
            AdminRepository adminRepo,
            ILogger <ApplicationServiceBehavior> logger)
        {
            _versions  = versions;
            _adminRepo = adminRepo;
            _logger    = logger;

            // Extract information from the Context Accessor
            _isServiceAccount = context.IsServiceAccount;
            if (_isServiceAccount)
            {
                _externalId = context.ExternalClientId ??
                              throw new InvalidOperationException($"The external client ID was not supplied.");
            }
            else
            {
                // This is a human user, so the external Id and email are required
                _externalId = context.ExternalUserId ??
                              throw new InvalidOperationException($"The external user ID was not supplied.");
                _externalEmail = context.ExternalEmail ??
                                 throw new InvalidOperationException($"The external user email was not supplied.");
            }

            _tenantId = context.TenantId ?? throw new ServiceException($"Tenant id was not supplied.");
            _appRepo  = repositoryFactory.GetRepository(_tenantId);
            _isSilent = context.IsSilent;
        }
Ejemplo n.º 2
0
 public ApplicationServiceBehavior(
     IApplicationRepositoryFactory repositoryFactory,
     ApplicationVersions versions,
     AdminRepository adminRepo,
     ILogger <ApplicationServiceBehavior> logger)
 {
     _repositoryFactory = repositoryFactory;
     _versions          = versions;
     _adminRepo         = adminRepo;
     _logger            = logger;
 }