Skip to content

Commit 2bd1314

Browse files
authored
Merge pull request #92 from UpendoVentures/dev
Merging dev and main
2 parents 7e04414 + 8968e7a commit 2bd1314

17 files changed

+706
-191
lines changed

Modules/UserManager/App_LocalResources/UserManageController.resx

-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,4 @@
120120
<data name="NotPermissions.Text" xml:space="preserve">
121121
<value>You do not have the necessary security permissions to use this application.</value>
122122
</data>
123-
<data name="UsernameInUse.Text" xml:space="preserve">
124-
<value>The username is already in use.</value>
125-
</data>
126123
</root>

Modules/UserManager/App_LocalResources/UserRoles.resx

+33
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,36 @@
123123
<data name="AddRole.Text" xml:space="preserve">
124124
<value>Add Role</value>
125125
</data>
126+
<data name="Cancel.Text" xml:space="preserve">
127+
<value>Cancel</value>
128+
</data>
129+
<data name="ClearDates.Text" xml:space="preserve">
130+
<value>Clear the Dates</value>
131+
</data>
132+
<data name="ClearStartEndDate.Text" xml:space="preserve">
133+
<value>This role has a start date and/or end date assigned to it. Clicking OK will clear those values. This action CANNOT be undone. Do you want to proceed?</value>
134+
</data>
135+
<data name="CorrectlyEdited.Text" xml:space="preserve">
136+
<value>Success: Correctly edited</value>
137+
</data>
126138
<data name="Delete.Text" xml:space="preserve">
127139
<value>Delete</value>
128140
</data>
141+
<data name="ErrorOccurred.Text" xml:space="preserve">
142+
<value>Error: an error has occurred</value>
143+
</data>
144+
<data name="Expires.Text" xml:space="preserve">
145+
<value>EXPIRES</value>
146+
</data>
147+
<data name="ExpiresDate.Text" xml:space="preserve">
148+
<value>Expires date</value>
149+
</data>
129150
<data name="NoRolesFounds.Text" xml:space="preserve">
130151
<value>No roles founds</value>
131152
</data>
153+
<data name="Ok.text" xml:space="preserve">
154+
<value>Ok</value>
155+
</data>
132156
<data name="Role.Text" xml:space="preserve">
133157
<value>ROLE</value>
134158
</data>
@@ -138,7 +162,16 @@
138162
<data name="SearchCriteria.Text" xml:space="preserve">
139163
<value>with this search criteria</value>
140164
</data>
165+
<data name="Start.Text" xml:space="preserve">
166+
<value>START</value>
167+
</data>
168+
<data name="StartDate.Text" xml:space="preserve">
169+
<value>Start date</value>
170+
</data>
141171
<data name="UserList.Text" xml:space="preserve">
142172
<value>User List</value>
143173
</data>
174+
<data name="YouAreSure.Text" xml:space="preserve">
175+
<value>You're sure?</value>
176+
</data>
144177
</root>

Modules/UserManager/Controllers/UserManageController.cs

+140-20
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1919

2020
using DotNetNuke.Entities.Users;
2121
using DotNetNuke.Framework.JavaScriptLibraries;
22+
using DotNetNuke.Instrumentation;
23+
using DotNetNuke.Security.Membership;
2224
using DotNetNuke.Security.Permissions;
2325
using DotNetNuke.Security.Roles;
2426
using DotNetNuke.Services.Localization;
2527
using DotNetNuke.Web.Mvc.Framework.ActionFilters;
2628
using DotNetNuke.Web.Mvc.Framework.Controllers;
2729
using System;
30+
using System.Net;
2831
using System.Web.Mvc;
32+
using Upendo.Modules.UserManager.Models.DnnModel;
2933
using Upendo.Modules.UserManager.Utility;
3034
using Upendo.Modules.UserManager.ViewModels;
35+
using static Telerik.Web.UI.OrgChartStyles;
3136

3237
namespace Upendo.Modules.UserManager.Controllers
3338
{
@@ -122,21 +127,48 @@ public ActionResult Create(UserViewModel item)
122127
{
123128
DotNetNuke.Framework.JavaScriptLibraries.JavaScript.RequestRegistration(CommonJs.DnnPlugins);
124129
var portalId = ModuleContext.PortalId;
125-
var user = UserController.GetUserByName(portalId, item.Username);
126130
ModelState.Remove("UserId");
127-
if (user != null)
131+
if (!ModelState.IsValid)
128132
{
129-
string errorMessage = Localization.GetString("UsernameInUse.Text", ResourceFile);
130-
ModelState.AddModelError(string.Empty, @errorMessage);
131133
return View(item);
132134
}
133-
134-
if (!ModelState.IsValid)
135+
var userCreateStatus = UserRepository.CreateUser(item, portalId);
136+
if (userCreateStatus == UserCreateStatus.Success)
137+
{
138+
return RedirectToAction("Index");
139+
}
140+
else
135141
{
142+
switch (userCreateStatus)
143+
{
144+
case UserCreateStatus.DuplicateEmail:
145+
ModelState.AddModelError("Email", "Duplicate; Email Address already in use on another User Account");
146+
break;
147+
case UserCreateStatus.InvalidEmail:
148+
ModelState.AddModelError("Email", "Invalid; Email Address did not pass validation");
149+
break;
150+
case UserCreateStatus.InvalidPassword:
151+
ModelState.AddModelError("Password", "Invalid; Password requirements were not met");
152+
break;
153+
case UserCreateStatus.BannedPasswordUsed:
154+
ModelState.AddModelError("Password", "Invalid; Password is banned");
155+
break;
156+
case UserCreateStatus.DuplicateUserName:
157+
case UserCreateStatus.UserAlreadyRegistered:
158+
case UserCreateStatus.UsernameAlreadyExists:
159+
ModelState.AddModelError("Username", "Duplicate; Username already in use on another User Account");
160+
break;
161+
case UserCreateStatus.InvalidUserName:
162+
ModelState.AddModelError("Username", "Invalid; Username does not meet requirements");
163+
break;
164+
default:
165+
ModelState.AddModelError(string.Empty, $"Create User Failed. Unhandled or Unknown UserCreateStatus: {userCreateStatus}");
166+
break;
167+
}
168+
string errorMessage = UserController.GetUserCreateStatus(userCreateStatus);
169+
ModelState.AddModelError(string.Empty, errorMessage);
136170
return View(item);
137171
}
138-
UserRepository.CreateUser(item, portalId);
139-
return RedirectToAction("Index");
140172
}
141173

142174
public ActionResult Edit(int itemId)
@@ -249,23 +281,111 @@ public ActionResult UserRoles(double? take, int? pageIndex, int? goToPage, strin
249281
var result1 = UserRepository.GetRolesByUser(takeValue, pageIndexValue, goToPage, portalId, search, itemId);
250282
return View(result1);
251283
}
252-
253-
if (roleId != null)
254-
{
255-
if (actionView == "Add")
256-
{
257-
RoleController.Instance.AddUserRole(portalId, itemId, roleIdValue, RoleStatus.Approved, false, DateTime.Now, DateTime.Now.AddDays(30));
258-
}
259-
else
260-
{
261-
RoleController.Instance.UpdateUserRole(portalId, itemId, roleIdValue, RoleStatus.Approved, false, true);
262-
}
263-
}
264284
ViewBag.User = UserRepository.GetUser(portalId, itemId);
265285
var result = UserRepository.GetRolesByUser(takeValue, pageIndexValue, goToPage, portalId, search, itemId);
266286
return View(result);
267287
}
268288
}
289+
290+
[HttpPost]
291+
public ActionResult AddUserRole(int itemId, int roleId)
292+
{
293+
bool isAuthenticated = Request.IsAuthenticated;
294+
// Check if the authenticated user has the required permission
295+
var hasPermission = Functions.HasPermission(ModuleContext);
296+
297+
if (!isAuthenticated || !hasPermission)
298+
{
299+
string errorMessage = Localization.GetString("NotPermissions.Text", ResourceFile);
300+
ViewBag.ErrorMessage = errorMessage;
301+
return View("Error");
302+
}
303+
else
304+
{
305+
try
306+
{
307+
var portalId = ModuleContext.PortalId;
308+
RoleController.Instance.AddUserRole(portalId, itemId, roleId, RoleStatus.Approved, false, DateTime.MinValue, DateTime.MinValue);
309+
}
310+
catch (Exception ex)
311+
{
312+
// Log the exception
313+
LoggerSource.Instance.GetLogger(typeof(UserRepository)).Error(ex);
314+
}
315+
return Content("");
316+
}
317+
}
318+
319+
[HttpPost]
320+
public ActionResult RemoveUserRole(int itemId, int roleId)
321+
{
322+
bool isAuthenticated = Request.IsAuthenticated;
323+
// Check if the authenticated user has the required permission
324+
var hasPermission = Functions.HasPermission(ModuleContext);
325+
326+
if (!isAuthenticated || !hasPermission)
327+
{
328+
string errorMessage = Localization.GetString("NotPermissions.Text", ResourceFile);
329+
ViewBag.ErrorMessage = errorMessage;
330+
return View("Error");
331+
}
332+
else
333+
{
334+
try
335+
{
336+
var portalId = ModuleContext.PortalId;
337+
RoleController.Instance.UpdateUserRole(portalId, itemId, roleId, RoleStatus.Approved, false, true);
338+
}
339+
catch (Exception ex)
340+
{
341+
// Log the exception
342+
LoggerSource.Instance.GetLogger(typeof(UserRepository)).Error(ex);
343+
}
344+
return Content("");
345+
}
346+
}
347+
348+
[HttpPost]
349+
public ActionResult UpdateDateTimeUserRole(int itemId, int roleId, DateTime? effectiveDate, DateTime? expiryDate)
350+
{
351+
try
352+
{
353+
var portalId = ModuleContext.PortalId;
354+
UserRepository.UpdateDateTimeUserRole(portalId, itemId, roleId, effectiveDate, expiryDate);
355+
}
356+
catch (Exception ex)
357+
{
358+
// Log the exception
359+
LoggerSource.Instance.GetLogger(typeof(UserRepository)).Error(ex);
360+
}
361+
return Content("");
362+
}
363+
364+
public ActionResult SetDateTimeUserRoleNull(int itemId, int roleId)
365+
{
366+
try
367+
{
368+
var portalId = ModuleContext.PortalId;
369+
var roleController = new RoleController();
370+
roleController.AddUserRole(portalId, itemId, roleId, DateTime.MinValue, DateTime.MinValue);
371+
372+
// Log the action
373+
var user = UserController.GetUserById(portalId, itemId);
374+
UserRoleInfo userRole = roleController.GetUserRole(portalId, itemId, roleId);
375+
var currentUser = UserController.Instance.GetCurrentUserInfo();
376+
377+
var logMessage = $"The effective date and expiration date for Role {userRole.FullName} were cleared for User {user.Username} by Username {currentUser.Username}.";
378+
var logger = LoggerSource.Instance.GetLogger(typeof(UserManageController));
379+
logger.Info(logMessage);
380+
}
381+
catch (Exception ex)
382+
{
383+
// Log the exception
384+
LoggerSource.Instance.GetLogger(typeof(UserManageController)).Error(ex);
385+
}
386+
return Content("");
387+
}
388+
269389
public ActionResult PasswordResetLink(int itemId)
270390
{
271391
var portalId = ModuleContext.PortalId;

Modules/UserManager/Module.css

+14
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,17 @@
337337
.color-black {
338338
color: black !important;
339339
}
340+
341+
/* version 1.01.02 additions */
342+
.field-validation-error {
343+
color: darkred;
344+
font-size: small;
345+
}
346+
347+
.datepicker-dropdown.datepicker-orient-left:after {
348+
left: 50% !important;
349+
}
350+
351+
.datepicker-dropdown.datepicker-orient-top:before {
352+
border-top: 0 solid rgba(0, 0, 0, .15) !important;
353+
}
+33-33
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
using System.Reflection;
2-
using System.Runtime.CompilerServices;
3-
using System.Runtime.InteropServices;
4-
5-
// General Information about an assembly is controlled through the following
6-
// set of attributes. Change these attribute values to modify the information
7-
// associated with an assembly.
8-
[assembly: AssemblyTitle("Upendo DNN User Manager Module for DNN")]
9-
[assembly: AssemblyDescription("Upendo DNN User Manager Extension for DNN")]
10-
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("Upendo Ventures, LLC")]
12-
[assembly: AssemblyProduct("UserManager Modules Extension for DNN")]
13-
[assembly: AssemblyCopyright("Copyright (C) Upendo Ventures, LLC")]
14-
[assembly: AssemblyTrademark("")]
15-
[assembly: AssemblyCulture("")]
16-
17-
// Setting ComVisible to false makes the types in this assembly not visible
18-
// to COM components. If you need to access a type in this assembly from
19-
// COM, set the ComVisible attribute to true on that type.
20-
[assembly: ComVisible(false)]
21-
22-
// The following GUID is for the ID of the typelib if this project is exposed to COM
23-
[assembly: Guid("8DB6F62D-9211-4721-820A-6F39CE44E058")]
24-
25-
// Version information for an assembly consists of the following four values:
26-
//
27-
// Major Version
28-
// Minor Version
29-
// Build Number
30-
// Revision
31-
//
32-
[assembly: AssemblyVersion("01.01.01")]
33-
[assembly: AssemblyFileVersion("01.01.01")]
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Upendo DNN User Manager Module for DNN")]
9+
[assembly: AssemblyDescription("Upendo DNN User Manager Extension for DNN")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Upendo Ventures, LLC")]
12+
[assembly: AssemblyProduct("UserManager Modules Extension for DNN")]
13+
[assembly: AssemblyCopyright("Copyright (C) Upendo Ventures, LLC")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("8DB6F62D-9211-4721-820A-6F39CE44E058")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
[assembly: AssemblyVersion("01.02.00")]
33+
[assembly: AssemblyFileVersion("01.02.00")]

Modules/UserManager/Upendo.Modules.UserManager.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
<Compile Include="ViewModels\Pagination.cs" />
110110
<Compile Include="ViewModels\ResultJsonViewModel.cs" />
111111
<Compile Include="ViewModels\RolesViewModel.cs" />
112+
<Compile Include="ViewModels\UserRoleDates.cs" />
112113
<Compile Include="ViewModels\UserViewModel.cs" />
113114
</ItemGroup>
114115
<ItemGroup>

Modules/UserManager/Upendo.UserManager.dnn

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<dotnetnuke type="Package" version="6.0">
33
<packages>
4-
<package name="Upendo.Modules.UserManager" type="Module" version="01.01.01">
4+
<package name="Upendo.Modules.UserManager" type="Module" version="01.02.00">
55
<friendlyName>Upendo DNN User Manager</friendlyName>
66
<description><![CDATA[<p>The Upendo DNN User Manager empowers authorized end-users in your DNN website to be able to manage user accounts and their assigned security roles.</p>]]></description>
77
<iconFile>DesktopModules/MVC/Upendo.Modules.UserManager/Images/logo.png</iconFile>
@@ -60,7 +60,7 @@
6060
<attributes>
6161
<businessControllerClass>Upendo.Modules.UserManager.Components.UserManagerController, Upendo.Modules.UserManager</businessControllerClass>
6262
<desktopModuleID>[DESKTOPMODULEID]</desktopModuleID>
63-
<upgradeVersionsList>01.00.00,01.01.00,01.01.01</upgradeVersionsList>
63+
<upgradeVersionsList>01.00.00,01.01.00,01.01.01,01.02.00</upgradeVersionsList>
6464
</attributes>
6565
</eventMessage>
6666
</component>
@@ -69,7 +69,7 @@
6969
<assembly>
7070
<name>Upendo.Modules.UserManager.dll</name>
7171
<path>bin</path>
72-
<version>01.01.01</version>
72+
<version>01.02.00</version>
7373
</assembly>
7474
</assemblies>
7575
</component>
@@ -92,7 +92,7 @@
9292
<script type="UnInstall">
9393
<path>Providers\DataProviders\SqlDataProvider</path>
9494
<name>Uninstall.SqlDataProvider</name>
95-
<version>01.01.01</version>
95+
<version>01.02.00</version>
9696
</script>
9797
</scripts>
9898
</component>

0 commit comments

Comments
 (0)