<p><code>{% requirePermission %}</code> can only take on parameter. To make your code a little easier to manage, you might want to check for false in your conditional and exit. That way you wont have to worry about closing the if statement later in your template code. You could even stick the code below in a partial <code>_checkPermissions.html</code> template to include on your pages that require it.</p>

<pre><code>{% if currentUser %}
    {% if not currentUser.can('perm1') and not currentUser.can('perm2')  %}
       {% exit 403 %}
    {% endif %}
{% else  %}
    {% exit 403 %}
{% endif %}
</code></pre>

CC BY-SA 3.0
2015-04-16T12:38:38.110Z
2015-04-16T12:46:01.060Z
2015-04-16T12:46:01.060Z
Aaron Berkowitz
<p>The <code>{% requirePermission 'perm1' %}</code> tag only supports a single permission. Behind the scenes it's <em>effectively</em> the same as:</p>

<pre><code>{% if not currentUser.can('perm1') %}
    {% exit 403 %}
{% endif %}
</code></pre>

<p>So I think either what you already have, or this:</p>

<pre><code>{% if not currentUser.can('perm1') and not currentUser.can('perm2') %}
    {% exit 403 %}
{% endif %}

&lt;!-- Your page stuff --&gt;
</code></pre>

<p>Is probably your best bet at the moment. Checking that the user <em>doesn't</em> have both permissions, is the same as checking they <em>do</em> have one or the other.</p>

CC BY-SA 3.0
2015-04-16T13:14:02.403Z
2015-04-16T13:31:01.277Z
2015-04-16T13:31:01.277Z
Mike Pepper
<p>I need to use requirePermission tag to check if one or another permission is active.</p>

<p>I want to reproduce something like this:</p>

<pre><code>{% if currentUser.can('perm1') or currentUser.can('perm2')  %}
   &lt;!-- My page stuff --&gt;
{% else %}
   {% exit 403 %}
{% endif %}
</code></pre>

<p>How can I make this possible <code>{% requirePermission "perm1_or_perm2" %}</code> ?</p>

CC BY-SA 3.0
2015-04-16T13:11:50.113Z
Why do you *need* to use `requirePermission` and can't just do it using `can`?
carlcs
<templating><permissions>
{% requirePermission %} with OR condition
# {% requirePermission %} with OR condition

(Asked by: username_0 on 2015-04-16)

I need to use requirePermission tag to check if one or another permission is active.
I want to reproduce something like this:
{% if currentUser.can('perm1') or currentUser.can('perm2')  %}
   
{% else %}
   {% exit 403 %}
{% endif %}

How can I make this possible {% requirePermission "perm1_or_perm2" %} ?

**Tags:** templating, permissions

> **Comments:**
> **username_1**: Why do you *need* to use `requirePermission` and can't just do it using `can`?  

---

## 2 answers

### Answer by username_3 on 2015-04-16. Score: 4 | Accepted answer

The {% requirePermission 'perm1' %} tag only supports a single permission. Behind the scenes it's effectively the same as:
{% if not currentUser.can('perm1') %}
    {% exit 403 %}
{% endif %}

So I think either what you already have, or this:
{% if not currentUser.can('perm1') and not currentUser.can('perm2') %}
    {% exit 403 %}
{% endif %}



Is probably your best bet at the moment. Checking that the user doesn't have both permissions, is the same as checking they do have one or the other.


---

### Answer by username_2 on 2015-04-16. Score: 3

{% requirePermission %} can only take on parameter. To make your code a little easier to manage, you might want to check for false in your conditional and exit. That way you wont have to worry about closing the if statement later in your template code. You could even stick the code below in a partial _checkPermissions.html template to include on your pages that require it.
{% if currentUser %}
    {% if not currentUser.can('perm1') and not currentUser.can('perm2')  %}
       {% exit 403 %}
    {% endif %}
{% else  %}
    {% exit 403 %}
{% endif %}


---

