SiteUser.isInRoles method

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
5/8/2009 10:08:11 AM
Gravatar
Total Posts 29
Thomas N. TALESIS SARL Conseil / Expertise en développement DOTNET

SiteUser.isInRoles method

Hi Joe,

I've developped some features where I use the roles to do some tests on users.
after renaming a role, the isInRoles method of the SiteUser class still returned the previous role name (I had to debug to see it)
I didn't investigate your code (I've just delete and create the good role, and assigned the users to make it work).

But I think there is something wrong with SiteUser.isInRoles method (?)
I mention that the Admin screens for roles and users managements works fine (I didn't notice any bugs )

Any idea ?

Best

Thomas.

5/8/2009 10:14:20 AM
Gravatar
Total Posts 18439

Re: SiteUser.isInRoles method

Hi Thomas,

When checking the current user's roles you should always use WebUser.IsInRoles not siteUser.IsInRoles to avoid un-needed database hits. siteUser.IsInRoles is used when the user whose roles are being checked is not the current user, but it is a little more expensive becuase it does hit the db.

Note that when you rename a role, it does not really rename the role it only changes the display name, so you must continue to use the original name in code checks. This makes it possible for example for you to rename the Admins role to something more localized but without breaking the system. If you really want to rename a role you should delte it and re-create it. Built in admins role is of course not allowed to be deleted.

Hope it helps,

Joe

5/8/2009 10:29:01 AM
Gravatar
Total Posts 29
Thomas N. TALESIS SARL Conseil / Expertise en développement DOTNET

Re: SiteUser.isInRoles method

Good informations, thank you Joe,

Thomas

 

You must sign in to post in the forums. This thread is closed to new posts.