XF 2.0 Permissions

AndrewSimm

Well-known member
I noticed that there appears to be two ways to use permissions in templates.

Code:
<xf:if is="$xf.visitor.canEditProfile()">

and
Code:
<xf:if is="{{ $xf.visitor.hasPermission('general', 'editCustomTitle') }}">

Obviously one of these is for editing profile and the other is for custom title but why is the syntax so different?
 
I think this is just a case where a shorthand has been created because the editProfile permission is checked in about 5 templates and the editCustomTitle is only used in 1. Both are equally valid.
 
If you check the canEditProfile() method on the user entity, it winds up calling hasPermission() as you'd expect. Generally permission methods are used for handling more complex situations where multiple permissions or other conditions may be involved in a single check.
 
Back
Top Bottom