# Best practices regarding querying authentication information multiple times

**URL:** <https://community.auth0.com/t/best-practices-regarding-querying-authentication-information-multiple-times/70005>\
**Category:** Get Help\
**Tags:** auth0-angular\
**Created:** [September 21, 2021, 8:08am UTC](https://community.auth0.com/t/best-practices-regarding-querying-authentication-information-multiple-times/70005 "2021-09-21T08:08:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![evert](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evert/32/30553_2.png) [@evert](https://community.auth0.com/u/evert)\
**Post date:** [September 21, 2021, 8:08am UTC](https://community.auth0.com/t/best-practices-regarding-querying-authentication-information-multiple-times/70005/1 "2021-09-21T08:08:06Z")

</div>

I have successfully implemented auth0 into my Angular SPA, but for the UX I have to query at multiple places the user information to hide/show some user elements. For example, a user with the role ‘admin’ is allowed to delete rows from a list, so then I show a delete button.

I have created a wrapper class which returns for example the user information. Example code (‘User’ is my own interface class):

```auto
public get userInfo$(): Observable<User> {
        return this._auth.user$.pipe(map(u => {
            var roles = u?.["<mynamespace url>"]["roles"];

            return {
                name : u?.name,
                email: u?.email,
                roles: roles
            } as User
        }));
    }

```

Now I wonder if I need to optimize/cache this kind of code or is it no problem to call this code multiple times.

---

<div class="post-metadata">

**Author:** ![sgo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sgo/32/13789_2.png) [@sgo](https://community.auth0.com/u/sgo)\
**Post date:** [September 21, 2021, 1:49pm UTC](https://community.auth0.com/t/best-practices-regarding-querying-authentication-information-multiple-times/70005/2 "2021-09-21T13:49:13Z")

</div>

Hi @evert ,

If you’re using our Angular SDK, this should be caching the user profile from the initial login’s returned ID token, into the `auth.user` object, so fetching the information multiple times across your app shouldn’t trigger any additional network traffic to Auth0 when using `auth.user` like the below quickstart section:

> **[Auth0 Angular SDK Quickstarts: Login](https://auth0.com/docs/quickstart/spa/angular/01-login#show-user-profile-information)**
>
> This tutorial demonstrates how to add user login to an Angular application using Auth0.

---

<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:** [October 6, 2021, 1:50pm UTC](https://community.auth0.com/t/best-practices-regarding-querying-authentication-information-multiple-times/70005/3 "2021-10-06T13:50:13Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
