From 97b3b693615e7a8e11f21b8b2cfa95e15cc7fbff Mon Sep 17 00:00:00 2001 From: seamys Date: Sat, 22 Dec 2018 14:14:16 +0800 Subject: [PATCH 1/5] This problem occurs when the administrator tries to lock the user and the data is changed, but the UI is never updated. --- src/Squidex.Domain.Users/UserWithClaims.cs | 6 ++++++ src/Squidex.Shared/Users/IUser.cs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/Squidex.Domain.Users/UserWithClaims.cs b/src/Squidex.Domain.Users/UserWithClaims.cs index 3231f5a674..cc42fedcef 100644 --- a/src/Squidex.Domain.Users/UserWithClaims.cs +++ b/src/Squidex.Domain.Users/UserWithClaims.cs @@ -5,6 +5,7 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== +using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; @@ -30,6 +31,11 @@ public string Email get { return Identity.Email; } } + public bool IsLocked + { + get { return Identity.LockoutEnd > DateTime.Now.ToUniversalTime(); } + } + IReadOnlyList IUser.Claims { get { return Claims; } diff --git a/src/Squidex.Shared/Users/IUser.cs b/src/Squidex.Shared/Users/IUser.cs index b863ff171f..2c0534095d 100644 --- a/src/Squidex.Shared/Users/IUser.cs +++ b/src/Squidex.Shared/Users/IUser.cs @@ -16,6 +16,8 @@ public interface IUser string Email { get; } + bool IsLocked { get; } + IReadOnlyList Claims { get; } } } From 564440e1c7246f05e3764ae8dd53821958a4c8dc Mon Sep 17 00:00:00 2001 From: seamys Date: Sat, 22 Dec 2018 15:36:40 +0800 Subject: [PATCH 2/5] fixed duplicate permission --- src/Squidex.Domain.Apps.Entities/Apps/RoleExtensions.cs | 2 +- .../Apps/RoleExtensionsRests.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Squidex.Domain.Apps.Entities/Apps/RoleExtensions.cs b/src/Squidex.Domain.Apps.Entities/Apps/RoleExtensions.cs index c9b0f7dfd4..0e0eddad92 100644 --- a/src/Squidex.Domain.Apps.Entities/Apps/RoleExtensions.cs +++ b/src/Squidex.Domain.Apps.Entities/Apps/RoleExtensions.cs @@ -30,7 +30,7 @@ public static string[] Prefix(this string[] permissions, string name) } } - permissions = result; + permissions = result.Distinct().ToArray(); return permissions; } diff --git a/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsRests.cs b/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsRests.cs index 5d4b8764d1..1e1117937d 100644 --- a/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsRests.cs +++ b/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsRests.cs @@ -23,6 +23,14 @@ public void Should_add_common_permission() Assert.Equal(new[] { "squidex.apps.my-app.common" }, result); } + [Fact] + public void Should_not_have_duplicate_permission() + { + var source = new[] { "common", "common", "common" }; + var result = source.Prefix("my-app"); + Assert.Single(result); + } + [Fact] public void Should_prefix_permission() { From 85e437d8d083373941fdc88f6345d0749de17e45 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 22 Dec 2018 09:23:29 +0100 Subject: [PATCH 3/5] Fixed file naming. --- .../Apps/{RoleExtensionsRests.cs => RoleExtensionsTests.cs} | 1 + 1 file changed, 1 insertion(+) rename tests/Squidex.Domain.Apps.Entities.Tests/Apps/{RoleExtensionsRests.cs => RoleExtensionsTests.cs} (99%) diff --git a/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsRests.cs b/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsTests.cs similarity index 99% rename from tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsRests.cs rename to tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsTests.cs index 1e1117937d..9e035ddd93 100644 --- a/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsRests.cs +++ b/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsTests.cs @@ -28,6 +28,7 @@ public void Should_not_have_duplicate_permission() { var source = new[] { "common", "common", "common" }; var result = source.Prefix("my-app"); + Assert.Single(result); } From 5fb0defbd243fabc3cc7bfa504e0740f768274a0 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 22 Dec 2018 23:36:46 +0100 Subject: [PATCH 4/5] Class name fixed. --- .../Apps/RoleExtensionsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsTests.cs b/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsTests.cs index 9e035ddd93..5cb8fb01b9 100644 --- a/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsTests.cs +++ b/tests/Squidex.Domain.Apps.Entities.Tests/Apps/RoleExtensionsTests.cs @@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Entities.Apps { - public class RoleExtensionsRests + public class RoleExtensionsTests { [Fact] public void Should_add_common_permission() From 58c0edb80eb7c14bc5afc77da8c0b5c3c59030fe Mon Sep 17 00:00:00 2001 From: seamys Date: Sun, 23 Dec 2018 16:40:34 +0800 Subject: [PATCH 5/5] renaming disabled to isDisabled --- .../app/framework/angular/forms/iframe-editor.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Squidex/app/framework/angular/forms/iframe-editor.component.ts b/src/Squidex/app/framework/angular/forms/iframe-editor.component.ts index 27f237315a..528eb663b1 100644 --- a/src/Squidex/app/framework/angular/forms/iframe-editor.component.ts +++ b/src/Squidex/app/framework/angular/forms/iframe-editor.component.ts @@ -65,7 +65,7 @@ export class IFrameEditorComponent implements ControlValueAccessor, AfterViewIni this.isInitialized = true; if (this.plugin.contentWindow && Types.isFunction(this.plugin.contentWindow.postMessage)) { - this.plugin.contentWindow.postMessage({ type: 'disabled', disabled: this.isDisabled }, '*'); + this.plugin.contentWindow.postMessage({ type: 'disabled', isDisabled: this.isDisabled }, '*'); this.plugin.contentWindow.postMessage({ type: 'valueChanged', value: this.value }, '*'); } } else if (type === 'resize') { @@ -99,7 +99,7 @@ export class IFrameEditorComponent implements ControlValueAccessor, AfterViewIni this.isDisabled = isDisabled; if (this.isInitialized && this.plugin.contentWindow && Types.isFunction(this.plugin.contentWindow.postMessage)) { - this.plugin.contentWindow.postMessage({ type: 'disabled', disabled: this.isDisabled }, '*'); + this.plugin.contentWindow.postMessage({ type: 'disabled', isDisabled: this.isDisabled }, '*'); } }