예제 #1
0
        public HttpResponseMessage UpdateGeneralSettings(AzureADB2CProviderSettings settings)
        {
            try
            {
                var config = new AzureConfig(AzureConfig.ServiceName, PortalId);
                if (!UserInfo.IsSuperUser)
                {
                    if (config.UseGlobalSettings || config.UseGlobalSettings != settings.UseGlobalSettings)
                    {
                        return(Request.CreateResponse(HttpStatusCode.Forbidden, "Only super users can change this setting"));
                    }
                }

                AzureADB2CProviderSettings.SaveGeneralSettings(AzureConfig.ServiceName, PortalId, settings);
                AddUserProfilePage(PortalId, settings.Enabled && !string.IsNullOrEmpty(settings.ProfilePolicy));

                // If UseGlobalSettigns was set to false, we have to create mappings if there're no mappings for the current portal
                if (config.UseGlobalSettings != settings.UseGlobalSettings && settings.UseGlobalSettings == false)
                {
                    PrepareUserMappingsForCurrentPortal();
                }

                return(Request.CreateResponse(HttpStatusCode.OK, new { Success = true }));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
예제 #2
0
 public HttpResponseMessage UpdateGeneralSettings(AzureADB2CProviderSettings settings)
 {
     try
     {
         AzureADB2CProviderSettings.SaveGeneralSettings("AzureB2C", PortalId, settings);
         AddUserProfilePage(PortalId, settings.Enabled && !string.IsNullOrEmpty(settings.ProfilePolicy));
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }