Skip to content

Commit

Permalink
Check accs
Browse files Browse the repository at this point in the history
  • Loading branch information
codergautam committed Jan 6, 2024
1 parent 388ac42 commit 020bb4a
Showing 1 changed file with 15 additions and 33 deletions.
48 changes: 15 additions & 33 deletions client/src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,40 +56,22 @@ function App() {
if(gameStarted && firstGame) setFirstGame(false);
if(gameStarted) return;
setTimeout(() => {
if(!getCookies().hasOwnProperty('auth-token') || !getCookies()['auth-token']) {
console.log('No auth token found, skipping account check');
setAccountReady(true);
return;
}
// if(!getCookies().hasOwnProperty('auth-token') || !getCookies()['auth-token']) {
// console.log('No auth token found, skipping account check');
// setAccountReady(true);
// return;
// }
console.log('Checking account');
// api.get(`${api.endpoint}/auth/account?now=${Date.now()}`, (data) => {
// console.log('Account data', data);
// setAccountReady(true);
// if (data.account) {
// data.account.token = data.token;
// dispatch(setAccount(data.account));
// } else {
// dispatch(clearAccount());
// }
// });
fetch(`${api.endpoint}/auth/account?now=${Date.now()}`, {
method: 'GET',
credentials: 'include',
})
.then((resp) => resp.json())
.then((data) => {
console.log('Account data', data);
setAccountReady(true);
if (data.account) {
data.account.token = data.token;
dispatch(setAccount(data.account));
} else {
dispatch(clearAccount());
}
})
.catch((err) => {
console.log('Error getting account', err);
});
api.get(`${api.endpoint}/auth/account?now=${Date.now()}`, (data) => {
console.log('Account data', data);
setAccountReady(true);
if (data.account) {
data.account.token = data.token;
dispatch(setAccount(data.account));
} else {
dispatch(clearAccount());
}
});
}, 10);

if(!firstGame) return;
Expand Down

0 comments on commit 020bb4a

Please sign in to comment.