Exemple #1
0
        public async Task SaveAsync(SsoConfig config, Organization organization)
        {
            var now = DateTime.UtcNow;

            config.RevisionDate = now;
            if (config.Id == default)
            {
                config.CreationDate = now;
            }

            var useKeyConnector = config.GetData().KeyConnectorEnabled;

            if (useKeyConnector)
            {
                await VerifyDependenciesAsync(config, organization);
            }

            var oldConfig = await _ssoConfigRepository.GetByOrganizationIdAsync(config.OrganizationId);

            var disabledKeyConnector = oldConfig?.GetData()?.KeyConnectorEnabled == true && !useKeyConnector;

            if (disabledKeyConnector && await AnyOrgUserHasKeyConnectorEnabledAsync(config.OrganizationId))
            {
                throw new BadRequestException("Key Connector cannot be disabled at this moment.");
            }

            await LogEventsAsync(config, oldConfig);

            await _ssoConfigRepository.UpsertAsync(config);
        }
        public OrganizationSsoResponseModel(Organization organization, GlobalSettings globalSettings,
                                            SsoConfig config = null) : base("organizationSso")
        {
            if (config != null)
            {
                Enabled = config.Enabled;
                Data    = config.GetData();
            }

            Urls = new SsoUrls(organization.Id.ToString(), globalSettings);
        }