Answers.Body: <p>You could loop through the users and compare them.</p>
  
  <pre><code>{% set authorized = false %}
  {% for user in entry.authorizedUsers %}
      {% if user == currentUser %}
          {% set authorized = true %}
      {% endif %}
  {% endfor %}
  
  {% if not authorized %}
      {% redirect 403 %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-10T23:39:34.963Z
Answers.Text: Ahha! I didn't know about redirect tag, will give that a shot, thanks
Answers.UserDisplayName: GlennJ
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-10T23:52:34.947Z
Answers.Text: Glad to help. Let me know if that first option works. I'm curious myself. Also, you can redirect anywhere with the `redirect` method (I just chose 403 as an example), or display alternate content if you like. You may also have to check if there is a currentUser at all, using `{% if currentUser %}... {% endif %}`
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-11T00:20:39.330Z
Answers.Text: Pretty sure Twig doesn't have an `in_array`.  It does have an `in`, so you could do `{% if not currentUser in entry.authorizedUsers %}`, but I doubt that will work when comparing whole objects to each other. Would probably need to just do the comparison on authorId, but honestly your 2nd solution seems better.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-11T18:56:35.503Z
Answers.Text: @Brad.... thanks. I was looking at a [post on the twig stack exchange](http://stackoverflow.com/questions/7460481/twig-in-array-or-similar-possible-within-if-statement) and misread it. As you say, still may not work.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-10T21:08:37.683Z
Answers.LastActivityDate: 2015-01-11T19:22:28.877Z
Answers.LastEditDate: 2015-01-11T19:22:28.877Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>I would like to protect the viewing of an _entry.html page so that only a user related to that entry can view it.</p>
  
Tags: <entry><authentication>
Title: Protect entry so that only a "relatedTo" user can see it
ThreadText: # Protect entry so that only a "relatedTo" user can see it
  
  (Asked by: username_0 on 2015-01-10)
  
  I would like to protect the viewing of an \_entry.html page so that only a user related to that entry can view it.
  
  **Tags:** entry, authentication
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-01-10. Score: 2
  
  You could loop through the users and compare them.
  
  ```
  {% set authorized = false %}
  {% for user in entry.authorizedUsers %}
      {% if user == currentUser %}
          {% set authorized = true %}
      {% endif %}
  {% endfor %}
  
  {% if not authorized %}
      {% redirect 403 %}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Ahha! I didn't know about redirect tag, will give that a shot, thanks  
  > **username_1**: Glad to help. Let me know if that first option works. I'm curious myself. Also, you can redirect anywhere with the `redirect` method (I just chose 403 as an example), or display alternate content if you like. You may also have to check if there is a currentUser at all, using `{% if currentUser %}... {% endif %}`  
  > **username_2**: Pretty sure Twig doesn't have an `in_array`.  It does have an `in`, so you could do `{% if not currentUser in entry.authorizedUsers %}`, but I doubt that will work when comparing whole objects to each other. Would probably need to just do the comparison on authorId, but honestly your 2nd solution seems better.  
  > **username_1**: @username_2.... thanks. I was looking at a [post on the twig stack exchange](http://stackoverflow.com/questions/7460481/twig-in-array-or-similar-possible-within-if-statement) and misread it. As you say, still may not work.  
  
  ---
  
  