New User Not Assigned A Role

Jan 27, 2014 at 3:59 PM
Edited Jan 27, 2014 at 4:01 PM
How do I assign a role to a new user? When I click on the new user's name I get a null reference error. I'm assuming that's because the new user has no role.

Also, the roles Admin and Moderator are not in the User Roles list box. How are they assigned?

This happens when I click on a new user's name:

Error: 1/27/2014 4:52:31 PM - NullReferenceException: Object reference not set to an instance of an object.
at PopForums.Extensions.HtmlHelpers.RoleCheckBoxes(HtmlHelper helper, String name, String[] checkedRoles) in c:\svn\forums\trunk\PopForums\Extensions\HtmlHelpers.cs:line 205
at ASP._Page_Areas_PopForums_Views_Admin_EditUser_cshtml.Execute() in c:\WWW\HospiceLinkForums\Web\Areas\PopForums\Views\Admin\EditUser.cshtml:line 203
Coordinator
Jan 27, 2014 at 5:45 PM
They aren't in the list box, because as it says on the role admin page: "Admin and Moderator are permanent roles, and can't be deleted." They're still created with the setup script and should appear in the roles table.

That said, you definitely found a bug (issue #122). If you're using the Ninject dependency resolver included in the code across your entire app (by setting it in your global.asax), you won't see the error. I've committed a fix to the source in Git, but haven't posted a new download.
Coordinator
Jan 27, 2014 at 5:46 PM
Jan 27, 2014 at 7:51 PM
Edited Jan 27, 2014 at 7:53 PM
Thank you for your help.

I'm not sure I explained myself well. I created roles called User and Viewer, which I intended to use for standard users to view or make posts.

I could have sworn there was a setting that said "Approve all new users" but I don't see it now. But, if the system can approve all new users, how can I assign a role to them automatically?

I thought I had to add roles to the Forum Permissions boxes to enable them. The reason why is that when I first set up the application, as Admin I couldn't see the forums I had created until I added them to the two outside boxes..

BTW, did you know the Admin and Moderator sometimes appear in the Forums Permissions middle box and sometimes don't? Seems entirely random.

I am an ASP.NET MVC developer, so I intend to study the code and see if I can assist you with anything. Hopefully I can contribute something in exchange for use of the software.
Coordinator
Jan 27, 2014 at 7:57 PM
All users are live as soon as they sign up. There's a checkbox to validate them, which means they need to follow a link emailed to them to verify they're for real.

You don't need to add roles to anything for default usage. If you put roles on specific forums, you can then restrict their viewing or posting to just those roles, but you still need to assign those roles to users. For example, I do this when I create a moderator forum, and assign people the mod role as needed.