Skip to content

Commit

Permalink
Fix for refreshing mid-profile request would log you out.
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn committed Sep 6, 2024
1 parent c066526 commit 43e5993
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/src/stores/user-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ export const useUserStore = defineStore('user', () => {
return data.value.signedUrl;
});


const authenticated = computed((): boolean => {
return data.value.accessToken !== null;
});
const authenticated = computed((): boolean => data.value.accessToken !== null);
/**
* @deprecated - Use authenticated
* @see this.authenticated
Expand Down Expand Up @@ -110,6 +107,11 @@ export const useUserStore = defineStore('user', () => {
const profile = async (call: Fetch): Promise<Error> => {
const { error, data: userData }: SubscriberResponse = await call('me').get().json();

// Type error means they refreshed midway through the request. Don't log them out for this!
if (error.value instanceof TypeError) {
return { error: error.value as unknown as string };
}

// Failed to get profile data, log this user out and return false
if (error.value || !userData.value) {
$reset();
Expand Down

0 comments on commit 43e5993

Please sign in to comment.