Check current user's role

Topics: Core, Customizing Orchard
Jul 13, 2013 at 7:39 AM
In razor syntax, have any code is used to check current user's role is Administrator, Moderator or Authenticated etc ?
Thanks :)
Developer
Jul 13, 2013 at 10:41 AM
Edited Jul 13, 2013 at 10:42 AM
Something like:
var roles = WorkContext.CurrentUser.As<UserRolesPart>().Roles;
If you're checking for permissions, you should not check for roles but against permissions using the Authorizer, e.g.:
var hasPermission = Authorizer.Authorize(StandardPermissions.AccessFrontEnd);
Jul 13, 2013 at 10:43 AM
sfmskywalker wrote:
Something like:
var roles = WorkContext.CurrentUser.As<UserRolesPart>().Roles;
If you're checking for permissions, you should not check for roles but against permissions using the Authorizer, e.g.:
var hasPermission = Authorizer.Authorize(StandardPermissions.AccessFrontEnd);
My thankfulness :)