only do API checks on logged-in state
This commit is contained in:
parent
fac0e28afb
commit
02ac28e832
|
@ -58,6 +58,7 @@ function App() {
|
||||||
const [ tokenChecked, setTokenChecked ] = React.useState(false);
|
const [ tokenChecked, setTokenChecked ] = React.useState(false);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
if (loginState == "login" || loginState == "callback") {
|
||||||
Promise.try(() => {
|
Promise.try(() => {
|
||||||
// Process OAUTH authorization token from URL if available
|
// Process OAUTH authorization token from URL if available
|
||||||
if (loginState == "callback") {
|
if (loginState == "callback") {
|
||||||
|
@ -75,15 +76,14 @@ function App() {
|
||||||
return dispatch(api.instance.fetch());
|
return dispatch(api.instance.fetch());
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// Check currently stored auth token for validity if available
|
// Check currently stored auth token for validity if available
|
||||||
if (loginState == "callback" || loginState == "login") {
|
|
||||||
return dispatch(api.user.fetchAccount());
|
return dispatch(api.user.fetchAccount());
|
||||||
}
|
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
setTokenChecked(true);
|
setTokenChecked(true);
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
setErrorMsg(e);
|
setErrorMsg(e);
|
||||||
console.error(e.message);
|
console.error(e.message);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
let ErrorElement = null;
|
let ErrorElement = null;
|
||||||
|
|
Loading…
Reference in New Issue