public override async Task <IDisplayResult> UpdateAsync(HttpsSettings settings, BuildEditorContext context) { if (context.GroupId == SettingsGroupId) { var user = _httpContextAccessor.HttpContext?.User; if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageHttps)) { return(null); } var model = new HttpsSettingsViewModel(); await context.Updater.TryUpdateModelAsync(model, Prefix); settings.EnableStrictTransportSecurity = model.EnableStrictTransportSecurity; settings.RequireHttps = model.RequireHttps; settings.RequireHttpsPermanent = model.RequireHttpsPermanent; settings.SslPort = model.SslPort; // If the settings are valid, release the current tenant. if (context.Updater.ModelState.IsValid) { await _shellHost.ReleaseShellContextAsync(_shellSettings); } } return(await EditAsync(settings, context)); }
public async Task <IActionResult> IndexPost(HttpsSettingsViewModel viewModel) { //if (!await _authorizationService.AuthorizeAsync(User, PermissionsProvider.ManageRoles)) //{ // return Unauthorized(); //} if (!ModelState.IsValid) { return(View(await GetModel())); } var settings = new HttpsSettings() { EnforceSsl = viewModel.EnforceSsl, UsePermanentRedirect = viewModel.UsePermanentRedirect, SslPort = viewModel.SslPort }; var result = await _httpsSettingsStore.SaveAsync(settings); if (result != null) { _alerter.Success(T["Settings Updated Successfully!"]); } else { _alerter.Danger(T["A problem occurred updating the settings. Please try again!"]); } return(RedirectToAction(nameof(Index))); }
public override async Task <IDisplayResult> UpdateAsync(HttpsSettings settings, BuildEditorContext context) { if (context.GroupId == SettingsGroupId) { var model = new HttpsSettingsViewModel(); await context.Updater.TryUpdateModelAsync(model, Prefix); settings.EnableStrictTransportSecurity = model.EnableStrictTransportSecurity; settings.RequireHttps = model.RequireHttps; settings.RequireHttpsPermanent = model.RequireHttpsPermanent; settings.SslPort = model.SslPort; // If the settings are valid, reload the current tenant. if (context.Updater.ModelState.IsValid) { await _shellHost.ReloadShellContextAsync(_shellSettings); } } return(await EditAsync(settings, context)); }
public override async Task <IDisplayResult> UpdateAsync(HttpsSettings settings, IUpdateModel updater, string groupId) { if (groupId == SettingsGroupId) { var model = new HttpsSettingsViewModel(); await updater.TryUpdateModelAsync(model, Prefix); settings.RequireHttps = model.RequireHttps; settings.RequireHttpsPermanent = model.RequireHttpsPermanent; settings.SslPort = model.SslPort; } if (_memoryCache.Get(RestartPendingCacheKey) == null) { var entry = _memoryCache.CreateEntry(RestartPendingCacheKey); _memoryCache.Set(entry.Key, entry, new MemoryCacheEntryOptions { Priority = CacheItemPriority.NeverRemove }); } return(Edit(settings)); }