# isAuthenticated() is always false

**URL:** <https://community.auth0.com/t/isauthenticated-is-always-false/84794>\
**Category:** Get Help\
**Created:** [June 8, 2022, 9:06am UTC](https://community.auth0.com/t/isauthenticated-is-always-false/84794 "2022-06-08T09:06:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnthonyDaSilva](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/anthonydasilva/32/33385_2.png) [@AnthonyDaSilva](https://community.auth0.com/u/AnthonyDaSilva)\
**Post date:** [June 8, 2022, 9:06am UTC](https://community.auth0.com/t/isauthenticated-is-always-false/84794/1 "2022-06-08T09:06:21Z")

</div>

Hey, I’m new to Auth0.  
I managed to make the react and javascript sample work but now I need to make it work for ExtJs.

The login seems to work but the isAuthenticated returns always false.  
The app is going in a loop : isAuthenticated = false → Login → already logged → IsAuthenticated = false → …

 ![image](https://global.discourse-cdn.com/auth0/original/3X/1/1/11e2234fd628994c661c5096de9f1225ce6123c5.png)

Probably a code issue as the application settings in auth0 works for the sample apps.

Edit : auth0.user is undefined

---

<div class="post-metadata">

**Author:** ![art.stupels](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/art.stupels/32/30429_2.png) [@art.stupels](https://community.auth0.com/u/art.stupels)\
**Post date:** [July 24, 2022, 12:52pm UTC](https://community.auth0.com/t/isauthenticated-is-always-false/84794/3 "2022-07-24T12:52:43Z")

</div>

You will need to use the [auth0.handleRedirectCallback()](https://auth0.github.io/auth0-spa-js/classes/auth0client.html#handleredirectcallback) function to handle success and error responses from Auth0.

```auto
try {
    auth0.isAuthenticated().then(async function (authenticated) {
        if (!authenticated) {
            const query = window.location.search;
            const shouldParseResult = query.includes("code=") && query.includes("state=");
            if (shouldParseResult) {
                console.log("> Parsing redirect");
                try {
                    const result = await auth0.handleRedirectCallback();
                    console.log("Logged in!");
                } catch (err) {
                    console.log("Error parsing redirect:", err);
                }
                window.history.replaceState({}, document.title, "/");
            } else {
                auth0.loginWithRedirect({ redirect_uri: window.location.origin });
            }
        } else {
            auth0.getTokenSilently().then(function (token) {
                Ext.Ajax.setDefaultHeaders({ 'Authorization': 'Bearer ' + token });
            });
        }
    })
} catch (err) {
    console.log("Log in failed", err);
}

```

Alternatively, you can the [useloginWithPopup()](https://auth0.github.io/auth0-spa-js/classes/auth0client.html#loginwithpopup) function:

```auto
if(!authenticated) {                      
    auth0.loginWithPopup().then(token => {
        auth0.getUser().then(user => {
            console.log(user);
        });
    })
 }

```

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 28, 2022, 10:38am UTC](https://community.auth0.com/t/isauthenticated-is-always-false/84794/4 "2022-07-28T10:38:14Z")

</div>

Thanks for helping on this one Art!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 28, 2022, 10:38am UTC](https://community.auth0.com/t/isauthenticated-is-always-false/84794/5 "2022-07-28T10:38:17Z")

</div>


