diff --git a/.gitignore b/.gitignore index eb67d6691..4855045e2 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ node_modules/ appsettings.Development.json appsettings.Production.json launchSettings.json + +/frontend/app-config/localhost-key.pem +/frontend/app-config/localhost.pem diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppClients.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppClients.cs index 943499b5d..aa3de0337 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppClients.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppClients.cs @@ -40,11 +40,6 @@ namespace Squidex.Domain.Apps.Core.Apps Guard.NotNullOrEmpty(id); Guard.NotNull(client); - if (ContainsKey(id)) - { - throw new ArgumentException("Id already exists.", nameof(id)); - } - return With(id, client); } diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppPatterns.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppPatterns.cs index 58403b473..90f6656fa 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppPatterns.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppPatterns.cs @@ -37,11 +37,6 @@ namespace Squidex.Domain.Apps.Core.Apps { var newPattern = new AppPattern(name, pattern, message); - if (ContainsKey(id)) - { - throw new ArgumentException("Id already exists.", nameof(id)); - } - return With(id, newPattern); } diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Roles.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Roles.cs index 0ee4fde5b..69da03ac0 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Roles.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Roles.cs @@ -93,7 +93,7 @@ namespace Squidex.Domain.Apps.Core.Apps if (inner.ContainsKey(name)) { - throw new ArgumentException("Name already exists.", nameof(name)); + return this; } if (IsDefault(name)) diff --git a/backend/src/Squidex/Areas/Frontend/Middlewares/WebpackMiddleware.cs b/backend/src/Squidex/Areas/Frontend/Middlewares/WebpackMiddleware.cs index 1ae6ac642..7d2ac538c 100644 --- a/backend/src/Squidex/Areas/Frontend/Middlewares/WebpackMiddleware.cs +++ b/backend/src/Squidex/Areas/Frontend/Middlewares/WebpackMiddleware.cs @@ -15,7 +15,7 @@ namespace Squidex.Areas.Frontend.Middlewares { public sealed class WebpackMiddleware { - private const string WebpackUrl = "http://localhost:3000/index.html"; + private const string WebpackUrl = "https://localhost:3000/index.html"; private readonly RequestDelegate next; @@ -28,7 +28,12 @@ namespace Squidex.Areas.Frontend.Middlewares { if (context.IsIndex() && context.Response.StatusCode != 304) { - using (var client = new HttpClient()) + var handler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = (message, cert, chain, error) => true + }; + + using (var client = new HttpClient(handler)) { var result = await client.GetAsync(WebpackUrl); diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/AppClientsTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/AppClientsTests.cs index bde13cbba..1e3ba2b96 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/AppClientsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/AppClientsTests.cs @@ -43,11 +43,11 @@ namespace Squidex.Domain.Apps.Core.Model.Apps } [Fact] - public void Should_throw_exception_if_assigning_client_object_with_same_id() + public void Should_do_nothing_if_assigning_client_object_with_same_id() { var clients_1 = clients_0.Add("2", "my-secret"); - Assert.Throws(() => clients_1.Add("2", new AppClient("my-name", "my-secret", "my-role"))); + clients_1.Add("2", new AppClient("my-name", "my-secret", "my-role")); } [Fact] diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/AppPatternsTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/AppPatternsTests.cs index 71e1391fb..151a74b1d 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/AppPatternsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/AppPatternsTests.cs @@ -35,11 +35,11 @@ namespace Squidex.Domain.Apps.Core.Model.Apps } [Fact] - public void Should_throw_exception_if_add_pattern_with_same_id() + public void Should_do_nothing_if_adding_pattern_with_same_id() { var patterns_1 = patterns_0.Add(id, "NewPattern", "New Pattern", "Message"); - Assert.Throws(() => patterns_1.Add(id, "NewPattern", "New Pattern", "Message")); + patterns_1.Add(id, "NewPattern", "New Pattern", "Message"); } [Fact] diff --git a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/RolesTests.cs b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/RolesTests.cs index c434a397e..522f74ef2 100644 --- a/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/RolesTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/RolesTests.cs @@ -45,11 +45,12 @@ namespace Squidex.Domain.Apps.Core.Model.Apps } [Fact] - public void Should_throw_exception_if_add_role_with_same_name() + public void Should_return_same_instance_if_adding_role_with_existing_name() { var roles_1 = roles_0.Add(role); + var roles_2 = roles_1.Add(role); - Assert.Throws(() => roles_1.Add(role)); + Assert.Same(roles_1, roles_2); } [Fact] diff --git a/frontend/app-config/webpack.config.js b/frontend/app-config/webpack.config.js index 7ee2d64aa..be6cc60bc 100644 --- a/frontend/app-config/webpack.config.js +++ b/frontend/app-config/webpack.config.js @@ -1,5 +1,6 @@ const webpack = require('webpack'), - path = require('path'); + path = require('path'), + fs = require('fs'); const appRoot = path.resolve(__dirname, '..'); @@ -209,8 +210,11 @@ module.exports = function (env) { headers: { 'Access-Control-Allow-Origin': '*' }, - https: true, - historyApiFallback: true + https: { + key: fs.readFileSync(path.resolve(__dirname, 'localhost-key.pem')), + cert: fs.readFileSync(path.resolve(__dirname, 'localhost.pem')), + }, + historyApiFallback: true, } }; @@ -257,7 +261,7 @@ module.exports = function (env) { /** * Set the public path, because we are running the website from another port (5000). */ - publicPath: 'http://localhost:3000/' + publicPath: 'https://localhost:3000/' }; } diff --git a/frontend/app/framework/angular/image-source.directive.ts b/frontend/app/framework/angular/image-source.directive.ts index dd78178a4..a2b94ae4f 100644 --- a/frontend/app/framework/angular/image-source.directive.ts +++ b/frontend/app/framework/angular/image-source.directive.ts @@ -125,7 +125,7 @@ export class ImageSourceDirective extends ResourceOwner implements OnChanges, On if (w > 0 && h > 0) { let source = this.imageSource; - source = StringHelper.appendToUrl(source, `${this.imageSource}&width=${w}&height=${h}&mode=Pad&nofocus`); + source = StringHelper.appendToUrl(source, `width=${w}&height=${h}&mode=Pad&nofocus`); if (this.loadQuery) { source = StringHelper.appendToUrl(source, 'q', this.loadQuery); @@ -138,7 +138,7 @@ export class ImageSourceDirective extends ResourceOwner implements OnChanges, On private retryLoadingImage() { this.loadRetries++; - if (this.loadRetries <= 10) { + if (this.loadRetries <= 3) { this.loadTimer = setTimeout(() => { this.loadQuery = MathHelper.guid(); diff --git a/frontend/app/framework/utils/string-helper.ts b/frontend/app/framework/utils/string-helper.ts index 0d760e68c..39664ec0e 100644 --- a/frontend/app/framework/utils/string-helper.ts +++ b/frontend/app/framework/utils/string-helper.ts @@ -20,8 +20,8 @@ export module StringHelper { return ''; } - export function appendToUrl(url: string, key: string, value?: any) { - if (url.indexOf('?') > 0) { + export function appendToUrl(url: string, key: string, value?: any, ambersand = false) { + if (url.indexOf('?') >= 0 || ambersand) { url += '&'; } else { url += '?'; diff --git a/frontend/app/shared/services/assets.service.ts b/frontend/app/shared/services/assets.service.ts index ad98eace0..d7e6b1061 100644 --- a/frontend/app/shared/services/assets.service.ts +++ b/frontend/app/shared/services/assets.service.ts @@ -216,7 +216,7 @@ export class AssetsService { fullQuery = `q=${encodeQuery(queryObj)}`; if (parentId) { - fullQuery = StringHelper.appendToUrl(fullQuery, 'parentId', parentId); + fullQuery = StringHelper.appendToUrl(fullQuery, 'parentId', parentId, true); } }