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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With