Skip to content

Commit

Permalink
Fix login page while connected (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
zlayine authored Aug 21, 2023
1 parent f0e66e1 commit 18e88b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions resources/js/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ export class ApiService {
if (resp.status === 401) {
useAppStore().clearLogin();
snackbar.error({ title: 'Unauthorized', text: 'Session expired, try to sign in again' });
return { field: 'Error', message: 'Unauthorized' };
throw { field: 'Error', message: 'Unauthorized' };
}

if (resp.status >= 400 && resp.status < 600) {
return resp as unknown as Error;
throw resp as unknown as Error;
}

return resp.json();
Expand Down
8 changes: 4 additions & 4 deletions resources/js/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export const useAppStore = defineStore('app', {
try {
this.setConfig();
if (!this.config.url) return false;
if (!this.isMultiTenant && !this.config.authorization_token.length) {
return false;
}

const urlConfig = await this.checkURL(this.config.url);
this.config.network = urlConfig.network;
Expand All @@ -73,12 +76,9 @@ export const useAppStore = defineStore('app', {
if (this.hasFuelTanksPackage) this.addFuelTanksNavigation();
if (this.hasMarketplacePackage) this.addMarketplaceNavigation();

this.loggedIn = true;
if (this.isMultiTenant && this.loggedIn) await this.getUser();

if (!this.isMultiTenant && this.config.url && this.config.authorization_token) {
this.loggedIn = true;
}

return await this.fetchCollectionIds();
} catch (error: any) {
snackbar.error({ title: error });
Expand Down

0 comments on commit 18e88b4

Please sign in to comment.