Skip to content

Commit

Permalink
Refresh if the user is logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
aleda145 committed Aug 5, 2022
1 parent c304092 commit 2ead137
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ export function getApiDomain() {

function App() {
const client = new PocketBase(getApiDomain());
const [isLoggedIn, setIsLoggedIn] = useState(client.AuthStore.isValid);

console.log(client.AuthStore.isValid);
console.log(client.AuthStore.model.email);
const [isLoggedIn, setIsLoggedIn] = useState(client.authStore.isValid);
if (isLoggedIn) {
console.log("refreshing");
client.users.refresh().catch((error) => {
console.log(error);
client.authStore.clear();
setIsLoggedIn(false);
});
}
if (!isLoggedIn) {
return <Auth client={client} setIsLoggedIn={setIsLoggedIn} />;
}
Expand Down

0 comments on commit 2ead137

Please sign in to comment.