Fix up UserGroup to map new property properly

This commit is contained in:
Nikolaj Geisle
2022-07-11 13:38:30 +02:00
parent bba403cf3e
commit 5bbb546780
5 changed files with 10 additions and 7 deletions

View File

@@ -11,7 +11,8 @@ public class ReadOnlyUserGroup : IReadOnlyUserGroup, IEquatable<ReadOnlyUserGrou
string? alias,
IEnumerable<int> allowedLanguages,
IEnumerable<string> allowedSections,
IEnumerable<string>? permissions)
IEnumerable<string>? permissions,
bool hasAccessToAllLanguages)
{
Name = name ?? string.Empty;
Icon = icon;
@@ -24,9 +25,10 @@ public class ReadOnlyUserGroup : IReadOnlyUserGroup, IEquatable<ReadOnlyUserGrou
// Zero is invalid and will be treated as Null
StartContentId = startContentId == 0 ? null : startContentId;
StartMediaId = startMediaId == 0 ? null : startMediaId;
HasAccessToAllLanguages = hasAccessToAllLanguages;
}
[Obsolete("please use ctor that takes allowedActions instead, scheduled for removal in v12")]
[Obsolete("please use ctor that takes allowedActions & hasAccessToAllLanguages instead, scheduled for removal in v12")]
public ReadOnlyUserGroup(
int id,
string? name,
@@ -36,7 +38,7 @@ public class ReadOnlyUserGroup : IReadOnlyUserGroup, IEquatable<ReadOnlyUserGrou
string? alias,
IEnumerable<string> allowedSections,
IEnumerable<string>? permissions)
: this(id, name, icon, startContentId, startMediaId, alias, Enumerable.Empty<int>(), allowedSections, permissions)
: this(id, name, icon, startContentId, startMediaId, alias, Enumerable.Empty<int>(), allowedSections, permissions, true)
{
}

View File

@@ -14,7 +14,7 @@ public static class UserGroupExtensions
}
// otherwise create one
return new ReadOnlyUserGroup(group.Id, group.Name, group.Icon, group.StartContentId, group.StartMediaId, group.Alias, group.AllowedLanguages, group.AllowedSections, group.Permissions);
return new ReadOnlyUserGroup(group.Id, group.Name, group.Icon, group.StartContentId, group.StartMediaId, group.Alias, group.AllowedLanguages, group.AllowedSections, group.Permissions, group.HasAccessToAllLanguages);
}
public static bool IsSystemUserGroup(this IUserGroup group) =>

View File

@@ -116,5 +116,6 @@ internal static class UserFactory
group.UserGroup2AppDtos.Select(x => x.AppAlias).WhereNotNull().ToArray(),
group.DefaultPermissions == null
? Enumerable.Empty<string>()
: group.DefaultPermissions.ToCharArray().Select(x => x.ToString()));
: group.DefaultPermissions.ToCharArray().Select(x => x.ToString()),
group.HasAccessToAllLanguages);
}

View File

@@ -431,7 +431,7 @@ public class UserGroupRepository : EntityRepositoryBase<int, IUserGroup>, IUserG
entity.Id = id;
PersistAllowedSections(entity);
PersistAllowedLanguages(entity);
PersistAllowedLanguages(entity);
entity.ResetDirtyProperties();
}

View File

@@ -116,7 +116,7 @@ public class UserEditorAuthorizationHelperTests
{
var currentUser = Mock.Of<IUser>(user => user.Groups == new[]
{
new ReadOnlyUserGroup(1, "CurrentUser", "icon-user", null, null, groupAlias, new int[0], new string[0], new string[0]),
new ReadOnlyUserGroup(1, "CurrentUser", "icon-user", null, null, groupAlias, new int[0], new string[0], new string[0], true),
});
IUser savingUser = null; // This means it is a new created user