# How to impersonate user in "read only" mode

**URL:** <https://community.auth0.com/t/how-to-impersonate-user-in-read-only-mode/6193>\
**Category:** Get Help\
**Tags:** custom-database\
**Created:** [April 12, 2017, 4:25am UTC](https://community.auth0.com/t/how-to-impersonate-user-in-read-only-mode/6193 "2017-04-12T04:25:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajyeoh](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ajyeoh](https://community.auth0.com/u/ajyeoh)\
**Post date:** [April 12, 2017, 4:25am UTC](https://community.auth0.com/t/how-to-impersonate-user-in-read-only-mode/6193/1 "2017-04-12T04:25:56Z")

</div>

I want my admins to be able to impersonate a user and see what they see, but not be able to change any settings for security reasons. How to do this? Thanks.

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [April 12, 2017, 9:58pm UTC](https://community.auth0.com/t/how-to-impersonate-user-in-read-only-mode/6193/2 "2017-04-12T21:58:09Z")

</div>

Based on the information available at ([https://auth0.com/docs/user-profile/user-impersonation](https://auth0.com/docs/user-profile/user-impersonation)) the rules engines is aware of the impersonation.

> In a Rule, you have access to `user.impersonated` and `user.impersonator` (the impersonating login) and you can write arbitrary Javascript to define how it works.

With this in mind you could setup a rule that when the token is issued as part of impersonation then it includes a claim indicating that fact, for example:

```
function (user, context, callback) {
  if(context.idToken && user.impersonated) {
    context.idToken"http://example.com/impersonated"] = true;
  }
  
  callback(null, user, context);
}

```

The final step would be for your application to react accordingly to the presence of this claim in the token and only allow read only access.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/how-to-impersonate-user-in-read-only-mode/6193/3 "2018-03-02T05:53:13Z")

</div>


