Skip to content

Commit

Permalink
fix loggedIn issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zlayine committed Sep 4, 2023
1 parent 4919859 commit 5d3ce30
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion resources/js/components/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="h-full flex flex-row">
<SideNavbar v-if="appStore.loggedIn" />
<SideNavbar v-if="appStore.hasValidConfig" />
<SnackbarGroup />

<div class="flex flex-col w-full overflow-hidden">
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/DisclosureMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<DisclosurePanel
class="fixed bg-white left-0 right-0 md:hidden divide-y divide-gray-200 shadow-md"
v-slot="{ close }"
v-if="appStore.hasValidConfig"
v-if="appStore.loggedIn"
>
<div class="space-y-1 py-2 px-4">
<RouterLink
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/NotificationsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ScaleTransition>
<MenuItems
class="absolute right-0 z-10 mt-2 w-72 sm:w-80 origin-top-right divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none pt-1"
v-if="appStore.hasValidConfig"
v-if="appStore.loggedIn"
>
<div class="max-h-80 overflow-y-auto divide-y divide-gray-100 scrollbar-hide">
<MenuItem
Expand Down
8 changes: 4 additions & 4 deletions resources/js/components/ProfileMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
<ScaleTransition>
<MenuItems
v-if="appStore.hasValidConfig"
v-if="appStore.loggedIn"
class="absolute right-0 z-10 mt-2 w-56 origin-top-right divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none pt-1"
>
<div class="px-4 py-2" v-if="appStore.user">
Expand All @@ -29,10 +29,10 @@
:address="appStore.user?.account"
/>
</div>
<div class="px-4 py-2" v-if="appStore.config.hostname">
<p class="text-sm text-gray-500">Hostname</p>
<div class="px-4 py-2" v-if="appStore.config.url">
<p class="text-sm text-gray-500">URL</p>
<p class="truncate text-sm font-medium text-gray-900">
{{ appStore.config.hostname }}
{{ appStore.config.url }}
</p>
</div>
<div class="px-4 py-2" v-if="appStore.config.network">
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<div class="">
<h1 class="text-xl md:text-2xl">
Wallet Account
<span v-if="!appStore.hasValidConfig && !walletAccount" class="text-red-500">&nbsp;*</span>
<span v-if="!appStore.loggedIn && !walletAccount" class="text-red-500">&nbsp;*</span>
</h1>
<p class="mt-1 text-sm text-gray-500 max-w-3xl">
The platform depends on there being a funded wallet daemon account setup and connected to
Expand Down
16 changes: 9 additions & 7 deletions resources/js/components/pages/Setup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ const setupAccount = async () => {
const parsedUrl = new URL(url.value);
if (!(await appStore.checkURL(parsedUrl))) return;
if (
await appStore.setupAccount({
url: parsedUrl,
authorization_token: authorizationToken.value,
})
) {
await appStore.setupAccount({
url: parsedUrl,
authorization_token: authorizationToken.value,
});
if (appStore.isMultiTenant) {
router.push({ name: 'platform.auth.login' });
} else {
redirectToCollections();
}
} catch (e: any) {
Expand All @@ -93,7 +95,7 @@ const setupAccount = async () => {
};
(async () => {
if (appStore.hasValidConfig) redirectToCollections();
if (appStore.loggedIn) redirectToCollections();
url.value = appStore.config.url as URL;
})();
Expand Down
4 changes: 2 additions & 2 deletions resources/js/components/pages/auth/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ const checkVerified = () => {
})();
watch(
() => appStore.hasValidConfig,
() => appStore.loggedIn,
() => {
if (appStore.hasValidConfig) router.push({ name: 'platform.collections' });
if (appStore.loggedIn) router.push({ name: 'platform.collections' });
}
);
</script>
6 changes: 4 additions & 2 deletions resources/js/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ 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();

return await this.fetchCollectionIds();
Expand All @@ -90,7 +89,9 @@ export const useAppStore = defineStore('app', {
async setupAccount({ url, authorization_token }: { url: URL; authorization_token: string }) {
this.url = url;
this.authorization_token = authorization_token;
this.loggedIn = true;
if (!this.isMultiTenant) {
this.loggedIn = true;
}

return await this.init();
},
Expand Down Expand Up @@ -158,6 +159,7 @@ export const useAppStore = defineStore('app', {
return true;
},
async login(email: string, password: string) {
this.loggedIn = true;
const res = await AuthApi.login(email, password);
if (!res.data.Login) throw [{ field: 'Login error', message: 'Invalid credentials' }];

Expand Down

0 comments on commit 5d3ce30

Please sign in to comment.