UpendoVentures / Upendo-Dnn-UserManager

This DNN CMS module allows authorized end-users to manage all of the common aspects of user management outside of the persona bar.
https://upendoventures.com/What/CMS/DNN
4 stars 3 forks source link

Unable to Create a New Role #48

Closed WillStrohl closed 1 year ago

WillStrohl commented 1 year ago

Sponsorship

If this request requires additional support (e.g., such as direct email/phone/meeting/development), I have the following interest in helping to sponsor the effot via GitHub Sponsors:

Describe the bug

When creating a new role, I get an exception.

Software Versions

To Reproduce

Steps to reproduce the behavior:

  1. Clean install of both.
  2. Add the module to any page.
  3. Click the Roles List button.
  4. Click the Create Role button.
  5. Add any role name. I used a real-world example of Press Team.
  6. Leave all other fields unchanged.
  7. Click the Save button to add the role.

Expected behavior

The role is added.

Actual behavior

A fatal and untrapped exception occurred.

Screenshots

N/A

Error log

Error: is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: System.Data.SqlClient.SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Roles_RoleGroups". The conflict occurred in database "Dev_UserManager", table "dbo.RoleGroups", column 'RoleGroupID'. The statement has been terminated.  
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)  
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)  
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)  
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()  
at System.Data.SqlClient.SqlDataReader.get_MetaData()  
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)  
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)  
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)  
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)  
at System.Data.SqlClient.SqlCommand.ExecuteScalar()  
at PetaPoco.Database.ExecuteScalarInternal[T](CommandType commandType, String sql, Object[] args)  
at DotNetNuke.Data.PetaPoco.PetaPocoHelper.ExecuteScalar[T](String connectionString, CommandType type, Int32 timeoutSec, String sql, Object[] args)  
at DotNetNuke.Data.SqlDataProvider.ExecuteScalar[T](String procedureName, Object[] commandParameters)  
at DotNetNuke.Security.Roles.DNNRoleProvider.CreateRole(RoleInfo role) ClientConnectionId:ce584174-466c-4d25-94cb-ef6652023447 Error Number:547,State:0,Class:16  
--->  
System.ArgumentException: System.Data.SqlClient.SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Roles_RoleGroups". The conflict occurred in database "Dev_UserManager", table "dbo.RoleGroups", column 'RoleGroupID'. The statement has been terminated.  
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)  
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)  
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)  
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()  
at System.Data.SqlClient.SqlDataReader.get_MetaData()  
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)  
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)  
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)  
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)  
at System.Data.SqlClient.SqlCommand.ExecuteScalar()  
at PetaPoco.Database.ExecuteScalarInternal[T](CommandType commandType, String sql, Object[] args)  
at DotNetNuke.Data.PetaPoco.PetaPocoHelper.ExecuteScalar[T](String connectionString, CommandType type, Int32 timeoutSec, String sql, Object[] args)  
at DotNetNuke.Data.SqlDataProvider.ExecuteScalar[T](String procedureName, Object[] commandParameters)  
at DotNetNuke.Security.Roles.DNNRoleProvider.CreateRole(RoleInfo role) ClientConnectionId:ce584174-466c-4d25-94cb-ef6652023447 Error Number:547,State:0,Class:16  
at DotNetNuke.Security.Roles.DNNRoleProvider.CreateRole(RoleInfo role)  
at DotNetNuke.Security.Roles.RoleController.DotNetNuke.Security.Roles.IRoleController.AddRole(RoleInfo role, Boolean addToExistUsers)  
at Upendo.Modules.UserManager.Utility.RolesRepository.CreateRol(RolesViewModel rol) in C:\Work\Dnn.Modules\UpendoUserManager\Upendo-Dnn-UserManager\Modules\UserManager\Utility\RolesRepository.cs:line 110  
at Upendo.Modules.UserManager.Controllers.RolesManageController.Create(RolesViewModel item) in C:\Work\Dnn.Modules\UpendoUserManager\Upendo-Dnn-UserManager\Modules\UserManager\Controllers\RolesManageController.cs:line 71  
at lambda_method(Closure , ControllerBase , Object[] )  
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)  
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)  
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()  
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)  
at DotNetNuke.Web.Mvc.Framework.Modules.ResultCapturingActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)  
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)  
at System.Web.Mvc.Controller.ExecuteCore()  
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)  
at DotNetNuke.Web.Mvc.Framework.Modules.ModuleApplication.ExecuteRequest(ModuleRequestContext context)  
at DotNetNuke.Web.Mvc.MvcHostControl.ExecuteModule()  
--- End of inner exception stack trace ---

Additional context

N/A

WillStrohl commented 1 year ago

Tests ran fine.