From 254de8b5fdfb262bd6a07d835dc02b4bdfe7ded9 Mon Sep 17 00:00:00 2001 From: Barbara Post Date: Tue, 26 Nov 2019 22:25:27 +0100 Subject: [PATCH 1/3] Add a private constructor to solve migration issue --- DataLayer/ExtraAuthClasses/ModulesForUser.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/DataLayer/ExtraAuthClasses/ModulesForUser.cs b/DataLayer/ExtraAuthClasses/ModulesForUser.cs index 4a53f6a..6122c19 100644 --- a/DataLayer/ExtraAuthClasses/ModulesForUser.cs +++ b/DataLayer/ExtraAuthClasses/ModulesForUser.cs @@ -13,6 +13,11 @@ namespace DataLayer.ExtraAuthClasses /// public class ModulesForUser : IChangeEffectsUser, IAddRemoveEffectsUser { + /// + /// Empty constructor for migration to work. + /// + private ModulesForUser() { } + /// /// This links modules to a user /// From d3ac9c9b66a38a36851c4b3927acfa875f0dcdbf Mon Sep 17 00:00:00 2001 From: Barbara Post Date: Tue, 26 Nov 2019 22:29:58 +0100 Subject: [PATCH 2/3] Use ArgumentException rather than InvalidOperationException --- DataLayer/ExtraAuthClasses/RoleToPermissions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataLayer/ExtraAuthClasses/RoleToPermissions.cs b/DataLayer/ExtraAuthClasses/RoleToPermissions.cs index 38f0fbc..1781424 100644 --- a/DataLayer/ExtraAuthClasses/RoleToPermissions.cs +++ b/DataLayer/ExtraAuthClasses/RoleToPermissions.cs @@ -69,7 +69,7 @@ public static IStatusGeneric CreateRoleWithPermissions(string public void Update(string description, ICollection permissions) { if (permissions == null || !permissions.Any()) - throw new InvalidOperationException("There should be at least one permission associated with a role."); + throw new ArgumentException("There should be at least one permission associated with a role.", nameof(permissions_)); _permissionsInRole = permissions.PackPermissionsIntoString(); Description = description; From 98f27701b9f24f9510b862b3d64cc6a809cabdd6 Mon Sep 17 00:00:00 2001 From: Barbara Post Date: Tue, 26 Nov 2019 22:44:31 +0100 Subject: [PATCH 3/3] Fix typo. Add another argument null check. --- DataLayer/ExtraAuthClasses/RoleToPermissions.cs | 2 +- DataLayer/ExtraAuthClasses/UserToRole.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/DataLayer/ExtraAuthClasses/RoleToPermissions.cs b/DataLayer/ExtraAuthClasses/RoleToPermissions.cs index 1781424..1daa993 100644 --- a/DataLayer/ExtraAuthClasses/RoleToPermissions.cs +++ b/DataLayer/ExtraAuthClasses/RoleToPermissions.cs @@ -69,7 +69,7 @@ public static IStatusGeneric CreateRoleWithPermissions(string public void Update(string description, ICollection permissions) { if (permissions == null || !permissions.Any()) - throw new ArgumentException("There should be at least one permission associated with a role.", nameof(permissions_)); + throw new ArgumentException("There should be at least one permission associated with a role.", nameof(permissions)); _permissionsInRole = permissions.PackPermissionsIntoString(); Description = description; diff --git a/DataLayer/ExtraAuthClasses/UserToRole.cs b/DataLayer/ExtraAuthClasses/UserToRole.cs index be4ed87..6918b6e 100644 --- a/DataLayer/ExtraAuthClasses/UserToRole.cs +++ b/DataLayer/ExtraAuthClasses/UserToRole.cs @@ -39,6 +39,7 @@ public UserToRole(string userId, RoleToPermissions role) public static IStatusGeneric AddRoleToUser(string userId, string roleName, ExtraAuthorizeDbContext context) { + if (userId == null) throw new ArgumentNullException(nameof(userId)); if (roleName == null) throw new ArgumentNullException(nameof(roleName)); var status = new StatusGenericHandler();