Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking if user authorized in Orchard CMS

I'm writing module for Orchard CMS, and I need show all parts of my Content Type only if user is authorized. Can I do it in View of my module (.cshtml)?

Something about this:

if(<statement_about_authorization>)
   @T("part_1"): @Model.part_1<br />
else
   @T("part_2"): @Model.part_2<br />

Or maybe with javascript?

like image 795
Max Zhukov Avatar asked Dec 16 '22 20:12

Max Zhukov


1 Answers

The normal User.Identity.IsAuthenticated will work, but Orchard has a nice way of authorizing your users based on defined permissions too...

@if(Authorizer.Authorize(Permissions.PermissionName){

}

You can read more about defining permissions here: Orchard Permissions

And an example from the blogs module on how to define your own permissions: Blog Permissions Example

like image 84
Brandon Joyce Avatar answered Dec 28 '22 15:12

Brandon Joyce