Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix login page while connected #28

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading