From 67f6695127764c64e610c88a5b329c219310d6f6 Mon Sep 17 00:00:00 2001 From: Jeremy Farrance Date: Wed, 6 Sep 2023 17:26:24 -0500 Subject: [PATCH 01/42] Tiny modification to show results of CreateUser, Issue #81 --- .../Controllers/UserManageController.cs | 15 +++++++++++++-- Modules/UserManager/Utility/UserRepository.cs | 5 +++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Modules/UserManager/Controllers/UserManageController.cs b/Modules/UserManager/Controllers/UserManageController.cs index a2a377e..c273ef9 100644 --- a/Modules/UserManager/Controllers/UserManageController.cs +++ b/Modules/UserManager/Controllers/UserManageController.cs @@ -19,6 +19,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using DotNetNuke.Entities.Users; using DotNetNuke.Framework.JavaScriptLibraries; +using DotNetNuke.Security.Membership; using DotNetNuke.Security.Permissions; using DotNetNuke.Security.Roles; using DotNetNuke.Services.Localization; @@ -135,8 +136,18 @@ public ActionResult Create(UserViewModel item) { return View(item); } - UserRepository.CreateUser(item, portalId); - return RedirectToAction("Index"); + var userCreateStatus = UserRepository.CreateUser(item, portalId); + if (userCreateStatus == UserCreateStatus.Success) + { + return RedirectToAction("Index"); + } + else + { + // TODO get localized versions of UserCreateStatus messages + // string errorMessage = Localization.GetString("NotPermissions.Text", ResourceFile); + ViewBag.ErrorMessage = $"Create User Failed with Error: {userCreateStatus}"; + return View("Error"); + } } public ActionResult Edit(int itemId) diff --git a/Modules/UserManager/Utility/UserRepository.cs b/Modules/UserManager/Utility/UserRepository.cs index 1fd11fd..3559aa3 100644 --- a/Modules/UserManager/Utility/UserRepository.cs +++ b/Modules/UserManager/Utility/UserRepository.cs @@ -222,12 +222,13 @@ public static UserViewModel GetUser(int portalId, int id) }; return user; } + /// /// Create User /// /// /// - public static void CreateUser(UserViewModel user, int portalId) + public static UserCreateStatus CreateUser(UserViewModel user, int portalId) { var userInfo = new UserInfo { @@ -249,7 +250,7 @@ public static void CreateUser(UserViewModel user, int portalId) { userInfo.Roles.Append(item.RoleName); } - UserController.CreateUser(ref userInfo, user.SendEmail); + return UserController.CreateUser(ref userInfo, user.SendEmail); } /// From abfd3a1f1c78cba0c777b78dd9cda9299a4d1908 Mon Sep 17 00:00:00 2001 From: Jeremy Farrance Date: Thu, 7 Sep 2023 18:25:21 -0500 Subject: [PATCH 02/42] Improved the UI to report the UserCreateStatus (error), #81 --- .../UserManager/Controllers/UserManageController.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Modules/UserManager/Controllers/UserManageController.cs b/Modules/UserManager/Controllers/UserManageController.cs index c273ef9..c9d0b8c 100644 --- a/Modules/UserManager/Controllers/UserManageController.cs +++ b/Modules/UserManager/Controllers/UserManageController.cs @@ -143,10 +143,14 @@ public ActionResult Create(UserViewModel item) } else { - // TODO get localized versions of UserCreateStatus messages - // string errorMessage = Localization.GetString("NotPermissions.Text", ResourceFile); - ViewBag.ErrorMessage = $"Create User Failed with Error: {userCreateStatus}"; - return View("Error"); + // expand this (using switch/case?) and handle all current DNN UserCreateStatus enums; e.g. UsernameALreadyExists, InvalidDisplayName, etc. + if (userCreateStatus == UserCreateStatus.DuplicateEmail) + { + ModelState.AddModelError("Email", "A user already exists with this email address"); + } + string errorMessage = $"Attempt to Save Failed with DNN Error: UserCreateStatus={userCreateStatus}"; + ModelState.AddModelError(string.Empty, errorMessage); + return View(item); } } From 689ee7f06141d767db82782a8470febf71643a27 Mon Sep 17 00:00:00 2001 From: Jeremy Farrance Date: Fri, 8 Sep 2023 15:18:04 -0500 Subject: [PATCH 03/42] More fixes and enhancements to Create User popup form. Added a releasenotes-10102.txt with a detailed recap of the changes.#81, #83 --- .../UserManageController.resx | 3 - .../Controllers/UserManageController.cs | 37 ++-- Modules/UserManager/Module.css | 6 + .../Views/UserManage/Create.cshtml | 158 +++++++++--------- Modules/UserManager/releasenotes-10102.txt | 42 +++++ 5 files changed, 153 insertions(+), 93 deletions(-) create mode 100644 Modules/UserManager/releasenotes-10102.txt diff --git a/Modules/UserManager/App_LocalResources/UserManageController.resx b/Modules/UserManager/App_LocalResources/UserManageController.resx index e042215..f832839 100644 --- a/Modules/UserManager/App_LocalResources/UserManageController.resx +++ b/Modules/UserManager/App_LocalResources/UserManageController.resx @@ -120,7 +120,4 @@ You do not have the necessary security permissions to use this application. - - The username is already in use. - \ No newline at end of file diff --git a/Modules/UserManager/Controllers/UserManageController.cs b/Modules/UserManager/Controllers/UserManageController.cs index c9d0b8c..0c956d3 100644 --- a/Modules/UserManager/Controllers/UserManageController.cs +++ b/Modules/UserManager/Controllers/UserManageController.cs @@ -123,15 +123,7 @@ public ActionResult Create(UserViewModel item) { DotNetNuke.Framework.JavaScriptLibraries.JavaScript.RequestRegistration(CommonJs.DnnPlugins); var portalId = ModuleContext.PortalId; - var user = UserController.GetUserByName(portalId, item.Username); ModelState.Remove("UserId"); - if (user != null) - { - string errorMessage = Localization.GetString("UsernameInUse.Text", ResourceFile); - ModelState.AddModelError(string.Empty, @errorMessage); - return View(item); - } - if (!ModelState.IsValid) { return View(item); @@ -143,12 +135,33 @@ public ActionResult Create(UserViewModel item) } else { - // expand this (using switch/case?) and handle all current DNN UserCreateStatus enums; e.g. UsernameALreadyExists, InvalidDisplayName, etc. - if (userCreateStatus == UserCreateStatus.DuplicateEmail) + switch (userCreateStatus) { - ModelState.AddModelError("Email", "A user already exists with this email address"); + case UserCreateStatus.DuplicateEmail: + ModelState.AddModelError("Email", "Duplicate; Email Address already in use on another User Account"); + break; + case UserCreateStatus.InvalidEmail: + ModelState.AddModelError("Email", "Invalid; Email Address did not pass validation"); + break; + case UserCreateStatus.InvalidPassword: + ModelState.AddModelError("Password", "Invalid; Password requirements were not met"); + break; + case UserCreateStatus.BannedPasswordUsed: + ModelState.AddModelError("Password", "Invalid; Password is banned"); + break; + case UserCreateStatus.DuplicateUserName: + case UserCreateStatus.UserAlreadyRegistered: + case UserCreateStatus.UsernameAlreadyExists: + ModelState.AddModelError("Username", "Duplicate; Username already in use on another User Account"); + break; + case UserCreateStatus.InvalidUserName: + ModelState.AddModelError("Username", "Invalid; Username does not meet requirements"); + break; + default: + ModelState.AddModelError(string.Empty, $"Create User Failed. Unhandled or Unknown UserCreateStatus: {userCreateStatus}"); + break; } - string errorMessage = $"Attempt to Save Failed with DNN Error: UserCreateStatus={userCreateStatus}"; + string errorMessage = UserController.GetUserCreateStatus(userCreateStatus); ModelState.AddModelError(string.Empty, errorMessage); return View(item); } diff --git a/Modules/UserManager/Module.css b/Modules/UserManager/Module.css index 1aa6bc7..c5a7712 100644 --- a/Modules/UserManager/Module.css +++ b/Modules/UserManager/Module.css @@ -337,3 +337,9 @@ .color-black { color: black !important; } + +/* version 1.01.02 additions */ +.field-validation-error { + color: darkred; + font-size: small; +} \ No newline at end of file diff --git a/Modules/UserManager/Views/UserManage/Create.cshtml b/Modules/UserManager/Views/UserManage/Create.cshtml index 545965c..495e644 100644 --- a/Modules/UserManager/Views/UserManage/Create.cshtml +++ b/Modules/UserManager/Views/UserManage/Create.cshtml @@ -3,91 +3,93 @@ @using System.Collections.Generic @using DotNetNuke.Web.Mvc.Helpers @using DotNetNuke.Services.Localization; +@using DotNetNuke.Security.Membership; @{ - string srcLogo = DotNetNuke.Entities.Tabs.TabController.CurrentPage.Title + - "/DesktopModules/MVC/Upendo.Modules.UserManager/Images/Upendo-logo-trans.png"; - string ResourceFile = "~/DesktopModules/MVC/Upendo.Modules.UserManager/App_LocalResources/AddEdit.resx"; + string srcLogo = DotNetNuke.Entities.Tabs.TabController.CurrentPage.Title + + "/DesktopModules/MVC/Upendo.Modules.UserManager/Images/Upendo-logo-trans.png"; + string ResourceFile = "~/DesktopModules/MVC/Upendo.Modules.UserManager/App_LocalResources/AddEdit.resx"; }
+
-
-

@Localization.GetString("CreateUser", @ResourceFile)

-
+

@Localization.GetString("CreateUser", @ResourceFile)

-
-
-
- - @Html.ValidationSummary(false, "", new { @class = "" }) -
-
-
- @Html.TextBoxFor(m => m.FirstName) - @Html.ValidationMessageFor(m => m.FirstName) -
-
-
- @Html.TextBoxFor(m => m.LastName) - @Html.ValidationMessageFor(m => m.LastName) -
-
-
- @Html.TextBoxFor(m => m.Username) - @Html.ValidationMessageFor(m => m.Username) -
-
-
- @Html.TextBoxFor(m => m.Email, new { @class = "form-control", @type = "email", id = "email", onkeyup = "validate();" }) -
- @Html.ValidationMessageFor(m => m.Email) -
-
-
-
- @Html.TextBoxFor(m => m.Password, new { @class = "form-control", @id = "password", @type = "password", onkeyup = "handlePasswordValidation();" }) - -
-
-
- @Html.TextBoxFor(m => m.ConfirmPassword, new { @id = "confirm_password", @type = "password", onkeyup = "validate();" }) - -
-
-
-
- @Html.CheckBoxFor(m => m.IsSuperUser, new { @id = "checkbox" }) - -
-
- @Html.CheckBoxFor(m => m.Approved, new { @id = "checkbox" }) - -
-
- @Html.CheckBoxFor(m => m.SendEmail, new { @id = "checkbox" }) - -
-
-
-
-
- - - @Localization.GetString("Cancel", @ResourceFile) - -
+
+
+
+
+ + @Html.ValidationSummary(false, "", new { @class = "" })
+
+
+ @Html.TextBoxFor(m => m.FirstName) + @Html.ValidationMessageFor(m => m.FirstName) +
+
+
+ @Html.TextBoxFor(m => m.LastName) + @Html.ValidationMessageFor(m => m.LastName) +
+
+
+ @Html.TextBoxFor(m => m.Username) + @Html.ValidationMessageFor(m => m.Username) +
+
+
+ @Html.TextBoxFor(m => m.Email, new { @class = "form-control", @type = "email", id = "email", onkeyup = "validate();" }) +
+ @Html.ValidationMessageFor(m => m.Email) +
+
+
+
+ @Html.TextBoxFor(m => m.Password, new { @class = "form-control", @id = "password", @type = "password", onkeyup = "handlePasswordValidation();" }) + @Html.ValidationMessageFor(m => m.Password) + +
+
+
+ @Html.TextBoxFor(m => m.ConfirmPassword, new { @id = "confirm_password", @type = "password", onkeyup = "validate();" }) + +
+
+
+
+ @Html.CheckBoxFor(m => m.IsSuperUser, new { @id = "checkbox" }) + +
+
+ @Html.CheckBoxFor(m => m.Approved, new { @id = "checkbox" }) + +
+
+ @Html.CheckBoxFor(m => m.SendEmail, new { @id = "checkbox" }) + +
+
+
+
+
+ + + @Localization.GetString("Cancel", @ResourceFile) + +
+
From 84a27b46012eb9d010dde34543fbfa5f1086db12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Wed, 15 May 2024 16:16:21 -0400 Subject: [PATCH 13/42] Update UserManageController.cs --- Modules/UserManager/Controllers/UserManageController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/UserManager/Controllers/UserManageController.cs b/Modules/UserManager/Controllers/UserManageController.cs index 4366cf4..54acf37 100644 --- a/Modules/UserManager/Controllers/UserManageController.cs +++ b/Modules/UserManager/Controllers/UserManageController.cs @@ -297,7 +297,7 @@ public ActionResult UserRoles(double? take, int? pageIndex, int? goToPage, strin } } - public ActionResult UpdateDateTimeUserRole(int itemId, int roleId,DateTime effectiveDate, DateTime expiryDate) + public ActionResult UpdateDateTimeUserRole(int itemId, int roleId,DateTime? effectiveDate, DateTime? expiryDate) { try { From 17a991958ce9bd08d0b4564b4a1394ebd4fb51f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Wed, 15 May 2024 16:16:24 -0400 Subject: [PATCH 14/42] Update Functions.cs --- Modules/UserManager/Utility/Functions.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Modules/UserManager/Utility/Functions.cs b/Modules/UserManager/Utility/Functions.cs index 06f44ba..8bf1ed2 100644 --- a/Modules/UserManager/Utility/Functions.cs +++ b/Modules/UserManager/Utility/Functions.cs @@ -252,10 +252,13 @@ public static bool HasPermission(DotNetNuke.UI.Modules.ModuleInstanceContext Mod return ModulePermissionController.HasModulePermission(permissions, "EDIT"); } - public static bool UpdateUserRoleDates(int userId, int roleId, DateTime effectiveDate, DateTime expiryDate) + public static bool UpdateUserRoleDates(int userId, int roleId, DateTime? effectiveDate, DateTime? expiryDate) { try { + var dataEffectiveDate = effectiveDate == null ? (object)DBNull.Value : effectiveDate; + var dataExpiryDate = expiryDate == null ? (object)DBNull.Value : expiryDate; + var connectionString = DotNetNuke.Common.Utilities.Config.GetConnectionString(); using (var connection = new SqlConnection(connectionString)) { @@ -263,15 +266,8 @@ public static bool UpdateUserRoleDates(int userId, int roleId, DateTime effectiv command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@UserID", userId); command.Parameters.AddWithValue("@RoleID", roleId); - - if (effectiveDate!=null) - { - command.Parameters.AddWithValue("@EffectiveDate", effectiveDate); - } - if (expiryDate != null) - { - command.Parameters.AddWithValue("@ExpiryDate", expiryDate); - } + command.Parameters.AddWithValue("@EffectiveDate", dataEffectiveDate); + command.Parameters.AddWithValue("@ExpiryDate", dataExpiryDate); connection.Open(); int rowsAffected = command.ExecuteNonQuery(); From fd1bc8aefea820ad31712b197b09ab4810406a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Wed, 15 May 2024 16:16:26 -0400 Subject: [PATCH 15/42] Update UserRepository.cs --- Modules/UserManager/Utility/UserRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/UserManager/Utility/UserRepository.cs b/Modules/UserManager/Utility/UserRepository.cs index b716728..c347efc 100644 --- a/Modules/UserManager/Utility/UserRepository.cs +++ b/Modules/UserManager/Utility/UserRepository.cs @@ -349,7 +349,7 @@ public static string SendPasswordResetLink(int portalId, int itemId, PortalSetti } } - public static bool UpdateDateTimeUserRole(int itemId, int roleId, DateTime effectiveDate, DateTime expiryDate) + public static bool UpdateDateTimeUserRole(int itemId, int roleId, DateTime? effectiveDate, DateTime? expiryDate) { try { From fd5a7287ad8ad1924e0001f4a4a9437227f1de42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Wed, 15 May 2024 17:36:03 -0400 Subject: [PATCH 16/42] Update UserManageController.cs --- Modules/UserManager/Controllers/UserManageController.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/UserManager/Controllers/UserManageController.cs b/Modules/UserManager/Controllers/UserManageController.cs index 54acf37..5c45907 100644 --- a/Modules/UserManager/Controllers/UserManageController.cs +++ b/Modules/UserManager/Controllers/UserManageController.cs @@ -301,7 +301,9 @@ public ActionResult UpdateDateTimeUserRole(int itemId, int roleId,DateTime? effe { try { - UserRepository.UpdateDateTimeUserRole(itemId, roleId, effectiveDate, expiryDate); + var portalId = ModuleContext.PortalId; + + UserRepository.UpdateDateTimeUserRole(portalId,itemId, roleId, effectiveDate, expiryDate); } catch (Exception ex) { From fd0f5eafbac93c9f1bd997d998e5067e71b7ebfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Wed, 15 May 2024 17:36:06 -0400 Subject: [PATCH 17/42] Update Upendo.Modules.UserManager.csproj --- Modules/UserManager/Upendo.Modules.UserManager.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/UserManager/Upendo.Modules.UserManager.csproj b/Modules/UserManager/Upendo.Modules.UserManager.csproj index 9e58075..aac95b0 100644 --- a/Modules/UserManager/Upendo.Modules.UserManager.csproj +++ b/Modules/UserManager/Upendo.Modules.UserManager.csproj @@ -109,6 +109,7 @@ + From 428a77b39c205deb4aa4ac39bb699b7512c68cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Wed, 15 May 2024 17:36:07 -0400 Subject: [PATCH 18/42] Update Functions.cs --- Modules/UserManager/Utility/Functions.cs | 43 +++++++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/Modules/UserManager/Utility/Functions.cs b/Modules/UserManager/Utility/Functions.cs index 8bf1ed2..bfd1600 100644 --- a/Modules/UserManager/Utility/Functions.cs +++ b/Modules/UserManager/Utility/Functions.cs @@ -30,6 +30,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using System.Data; using DotNetNuke.Instrumentation; using DotNetNuke.Services.Localization; +using static Telerik.Web.UI.OrgChartStyles; +using DotNetNuke.Security.Roles; namespace Upendo.Modules.UserManager.Utility { @@ -252,13 +254,16 @@ public static bool HasPermission(DotNetNuke.UI.Modules.ModuleInstanceContext Mod return ModulePermissionController.HasModulePermission(permissions, "EDIT"); } - public static bool UpdateUserRoleDates(int userId, int roleId, DateTime? effectiveDate, DateTime? expiryDate) + public static bool UpdateUserRoleDates(int portalId, int userId, int roleId, DateTime? effectiveDate, DateTime? expiryDate) { try { - var dataEffectiveDate = effectiveDate == null ? (object)DBNull.Value : effectiveDate; - var dataExpiryDate = expiryDate == null ? (object)DBNull.Value : expiryDate; + var user = UserController.GetUserById(portalId, userId); + var userRoleDates = GetUserRoleDates(portalId, userId, roleId); + var dataEffectiveDate = effectiveDate == null ? (userRoleDates.EffectiveDate == DateTime.MinValue ? (object)DBNull.Value : userRoleDates.EffectiveDate) : effectiveDate; + var dataExpiryDate = expiryDate == null ? (userRoleDates.ExpiryDate == DateTime.MinValue ? (object)DBNull.Value : userRoleDates.ExpiryDate) : expiryDate; + var connectionString = DotNetNuke.Common.Utilities.Config.GetConnectionString(); using (var connection = new SqlConnection(connectionString)) { @@ -266,8 +271,8 @@ public static bool UpdateUserRoleDates(int userId, int roleId, DateTime? effecti command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@UserID", userId); command.Parameters.AddWithValue("@RoleID", roleId); - command.Parameters.AddWithValue("@EffectiveDate", dataEffectiveDate); - command.Parameters.AddWithValue("@ExpiryDate", dataExpiryDate); + command.Parameters.AddWithValue("@EffectiveDate", dataEffectiveDate); + command.Parameters.AddWithValue("@ExpiryDate", dataExpiryDate); connection.Open(); int rowsAffected = command.ExecuteNonQuery(); @@ -281,5 +286,33 @@ public static bool UpdateUserRoleDates(int userId, int roleId, DateTime? effecti return false; } } + + public static UserRoleDates GetUserRoleDates(int portalId, int userId, int roleId) + { + var userRoleDates = new UserRoleDates(); + + try + { + // Get the user + UserInfo user = UserController.GetUserById(portalId, userId); + // Get the RoleController instance + RoleController roleController = new RoleController(); + + // Get the user role + UserRoleInfo userRole = roleController.GetUserRole(portalId, userId, roleId); + userRoleDates = new UserRoleDates + { + EffectiveDate = userRole.EffectiveDate, + ExpiryDate = userRole.ExpiryDate + }; + } + catch (Exception ex) + { + LoggerSource.Instance.GetLogger(typeof(UserRepository)).Error(ex); + } + + // Return EffectiveDate and ExpiryDate + return userRoleDates; + } } } \ No newline at end of file From f5708f36c111e3d9b549a3f9fe14cc9df13234c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Wed, 15 May 2024 17:36:09 -0400 Subject: [PATCH 19/42] Update UserRepository.cs --- Modules/UserManager/Utility/UserRepository.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/UserManager/Utility/UserRepository.cs b/Modules/UserManager/Utility/UserRepository.cs index c347efc..508c3bf 100644 --- a/Modules/UserManager/Utility/UserRepository.cs +++ b/Modules/UserManager/Utility/UserRepository.cs @@ -349,11 +349,11 @@ public static string SendPasswordResetLink(int portalId, int itemId, PortalSetti } } - public static bool UpdateDateTimeUserRole(int itemId, int roleId, DateTime? effectiveDate, DateTime? expiryDate) + public static bool UpdateDateTimeUserRole(int portalId, int itemId, int roleId, DateTime? effectiveDate, DateTime? expiryDate) { try { - return Functions.UpdateUserRoleDates( itemId, roleId, effectiveDate, expiryDate); + return Functions.UpdateUserRoleDates(portalId, itemId, roleId, effectiveDate, expiryDate); } catch (Exception ex) { From a75b6d386d3bd65f40c77e1b0b039785d91abf3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Wed, 15 May 2024 17:36:11 -0400 Subject: [PATCH 20/42] Update RolesViewModel.cs --- Modules/UserManager/ViewModels/RolesViewModel.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/UserManager/ViewModels/RolesViewModel.cs b/Modules/UserManager/ViewModels/RolesViewModel.cs index b3a1c3b..c961286 100644 --- a/Modules/UserManager/ViewModels/RolesViewModel.cs +++ b/Modules/UserManager/ViewModels/RolesViewModel.cs @@ -40,5 +40,7 @@ public class RolesViewModel public RoleType RoleType { get; set; } public bool HasRole { get; set; } public int? Index { get; set; } + public DateTime? EffectiveDate { get; set; } + public DateTime? ExpiryDate { get; set; } } } \ No newline at end of file From 278f8ea86f1d1960e8aa181dcb3f43663f3114ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Wed, 15 May 2024 17:36:13 -0400 Subject: [PATCH 21/42] Create UserRoleDates.cs --- Modules/UserManager/ViewModels/UserRoleDates.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Modules/UserManager/ViewModels/UserRoleDates.cs diff --git a/Modules/UserManager/ViewModels/UserRoleDates.cs b/Modules/UserManager/ViewModels/UserRoleDates.cs new file mode 100644 index 0000000..fc28b76 --- /dev/null +++ b/Modules/UserManager/ViewModels/UserRoleDates.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Upendo.Modules.UserManager.ViewModels +{ + public class UserRoleDates + { + public DateTime EffectiveDate { get; set; } + public DateTime ExpiryDate { get; set; } + } +} \ No newline at end of file From d76e759136d2f2bc88bf56486c4b45ab7213dd12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Wed, 15 May 2024 17:36:15 -0400 Subject: [PATCH 22/42] Update UserRoles.cshtml --- .../Views/UserManage/UserRoles.cshtml | 88 ++++++++----------- 1 file changed, 39 insertions(+), 49 deletions(-) diff --git a/Modules/UserManager/Views/UserManage/UserRoles.cshtml b/Modules/UserManager/Views/UserManage/UserRoles.cshtml index 6a446e7..783431d 100644 --- a/Modules/UserManager/Views/UserManage/UserRoles.cshtml +++ b/Modules/UserManager/Views/UserManage/UserRoles.cshtml @@ -112,9 +112,9 @@ @item.RoleName - +
- + @@ -122,9 +122,9 @@ - +
- + @@ -175,55 +175,45 @@
From 13148406b0813d55cfb3cf0aca875dd18f4b9289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Mon, 20 May 2024 11:34:32 -0400 Subject: [PATCH 31/42] Update UserRoles.resx --- .../App_LocalResources/UserRoles.resx | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Modules/UserManager/App_LocalResources/UserRoles.resx b/Modules/UserManager/App_LocalResources/UserRoles.resx index 9a0aef0..466650d 100644 --- a/Modules/UserManager/App_LocalResources/UserRoles.resx +++ b/Modules/UserManager/App_LocalResources/UserRoles.resx @@ -123,9 +123,24 @@ Add Role + + Clear the Dates + + + Success: Correctly edited + Delete + + Error: an error has occurred + + + EXPIRES + + + Expires date + No roles founds @@ -138,6 +153,12 @@ with this search criteria + + START + + + Start date + User List From b1acff47c3cd6cd59ffac756413d1a28ed4f745c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Mon, 20 May 2024 11:34:35 -0400 Subject: [PATCH 32/42] Update UserManageController.cs --- .../Controllers/UserManageController.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Modules/UserManager/Controllers/UserManageController.cs b/Modules/UserManager/Controllers/UserManageController.cs index 221e829..de36ef5 100644 --- a/Modules/UserManager/Controllers/UserManageController.cs +++ b/Modules/UserManager/Controllers/UserManageController.cs @@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using DotNetNuke.Web.Mvc.Framework.Controllers; using System; using System.Web.Mvc; +using Upendo.Modules.UserManager.Models.DnnModel; using Upendo.Modules.UserManager.Utility; using Upendo.Modules.UserManager.ViewModels; using static Telerik.Web.UI.OrgChartStyles; @@ -312,6 +313,22 @@ public ActionResult UpdateDateTimeUserRole(int itemId, int roleId,DateTime? effe } return Content(""); } + + public ActionResult SetDateTimeUserRoleNull(int itemId, int roleId) + { + try + { + var portalId = ModuleContext.PortalId; + var roleController = new RoleController(); + roleController.AddUserRole(portalId, itemId, roleId, DateTime.MinValue, DateTime.MinValue); + } + catch (Exception ex) + { + // Log the exception + LoggerSource.Instance.GetLogger(typeof(UserRepository)).Error(ex); + } + return Content(""); + } public ActionResult PasswordResetLink(int itemId) { From 5416cb4fa82a92d1143a83803e140ba6e476035c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rom=C3=A1n=20Franco?= Date: Mon, 20 May 2024 11:34:38 -0400 Subject: [PATCH 33/42] Update UserRoles.cshtml --- .../Views/UserManage/UserRoles.cshtml | 105 +++++++++++++----- 1 file changed, 80 insertions(+), 25 deletions(-) diff --git a/Modules/UserManager/Views/UserManage/UserRoles.cshtml b/Modules/UserManager/Views/UserManage/UserRoles.cshtml index 3b9fc48..e4126d2 100644 --- a/Modules/UserManager/Views/UserManage/UserRoles.cshtml +++ b/Modules/UserManager/Views/UserManage/UserRoles.cshtml @@ -83,9 +83,9 @@ @Localization.GetString("Role", @ResourceFile) - START - EXPIRES - @Localization.GetString("Actions", @ResourceFile) + @Localization.GetString("Start", @ResourceFile) + @Localization.GetString("Expires", @ResourceFile) + @Localization.GetString("Actions", @ResourceFile) @@ -111,18 +111,18 @@ @item.RoleName - +

@(item.EffectiveDate.HasValue && item.EffectiveDate.Value != DateTime.MinValue ? item.EffectiveDate.Value.ToString("yyyy-MM-dd") : "")

- +

@(item.ExpiryDate.HasValue && item.ExpiryDate.Value != DateTime.MinValue ? item.ExpiryDate.Value.ToString("yyyy-MM-dd") : "")

-
+
@@ -130,7 +130,7 @@
- +
@@ -138,19 +138,23 @@
- + + + + + @if (@item.HasRole == true) { - + } else { - + } @@ -159,6 +163,22 @@ } +