@@ -8,7 +8,12 @@ import user from './user.store';
88import scope from './scope.store' ;
99import features from './features.store' ;
1010
11+ let shouldFetch = true ;
12+
1113async function fetchUser ( commit ) {
14+ if ( shouldFetch === false ) {
15+ return
16+ }
1217 try {
1318 const fetchPolicy = 'network-only' ;
1419 const { data } = await client . query ( {
@@ -19,14 +24,21 @@ async function fetchUser(commit) {
1924 commit ( 'setUser' , data . profile ) ;
2025 return true ;
2126 } catch ( e ) {
22- const {
23- graphQLErrors : [ { message } ] ,
24- } = e ;
25- if ( message === 'wait_for_profile' ) {
26- console . log ( 'creating' ) ;
27- }
28- commit ( 'setUser' , { loggedIn : true } ) ;
29- return false ;
27+ try {
28+ const {
29+ graphQLErrors : [ { message } ] ,
30+ } = e ;
31+ if ( message === 'wait_for_profile' ) {
32+ console . log ( 'creating' ) ;
33+ }
34+ commit ( 'setUser' , { loggedIn : true } ) ;
35+ return false ;
36+ }
37+ catch ( e ) {
38+ // Probably getting a 403 for authentication
39+ shouldFetch = false
40+ return false
41+ }
3042 }
3143}
3244
@@ -101,4 +113,4 @@ export async function resolvePromisesSerially(promises, resolvers) {
101113 console . error ( e . message ) ;
102114 throw new Error ( e . message ) ;
103115 }
104- }
116+ }
0 commit comments