diff --git a/examples/with-supertokens/package.json b/examples/with-supertokens/package.json index ac40d1262d..b98f6ca226 100644 --- a/examples/with-supertokens/package.json +++ b/examples/with-supertokens/package.json @@ -11,7 +11,7 @@ "next": "latest", "react": "17.0.1", "react-dom": "17.0.1", - "supertokens-auth-react": "^0.12.0", + "supertokens-auth-react": "^0.13.0", "supertokens-node": "^5.0.0" }, "license": "MIT" diff --git a/examples/with-supertokens/pages/index.js b/examples/with-supertokens/pages/index.js index 00284df70e..befe0d5d5c 100644 --- a/examples/with-supertokens/pages/index.js +++ b/examples/with-supertokens/pages/index.js @@ -42,13 +42,17 @@ export default function Home(props) { function ProtectedPage({ userId }) { async function logoutClicked() { await ThirdPartyEmailPassword.signOut() - window.location.href = '/auth' + ThirdPartyEmailPassword.redirectToAuth() } async function fetchUserData() { const res = await fetch('/api/user') - const json = await res.json() - alert(JSON.stringify(json)) + if (res.status === 401) { + ThirdPartyEmailPassword.redirectToAuth() + } else { + const json = await res.json() + alert(JSON.stringify(json)) + } } return (