Fix navigation after login
This commit is contained in:
parent
3379251ccb
commit
ed6dde2f0a
5 changed files with 8 additions and 12 deletions
|
|
@ -44,7 +44,7 @@ class ApiClient {
|
|||
return this._isAuthenticated;
|
||||
}
|
||||
|
||||
setLoggedIn(value: boolean): void {
|
||||
setAuthenticated(value: boolean): void {
|
||||
this._isAuthenticated = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,15 +10,7 @@
|
|||
Active Investigation Workbench
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="map-container" v-if="session.organization">
|
||||
<MapMultipoint
|
||||
id="map"
|
||||
:bounds="session.organization.service_area"
|
||||
:markers="markers"
|
||||
:organizationId="session.organization.id"
|
||||
:tegola="session.urls?.tegola ?? ''"
|
||||
></MapMultipoint>
|
||||
</div>
|
||||
<div class="map-container" v-if="session.organization"></div>
|
||||
<div v-else>
|
||||
<p>loading...</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -224,13 +224,13 @@ router.beforeEach(async (to, from) => {
|
|||
try {
|
||||
// Check if user is authenticated (could be an API call)
|
||||
if (!apiClient.isAuthenticated) {
|
||||
return "/_/signin";
|
||||
return "/signin";
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("check auth failed");
|
||||
return "/_/signin";
|
||||
return "/signin";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ export const useSessionStore = defineStore("session", () => {
|
|||
|
||||
try {
|
||||
const data: Session = await apiClient.JSONGet("/api/session");
|
||||
apiClient.setAuthenticated(true);
|
||||
impersonating.value = data.impersonating || null;
|
||||
notification_counts.value = data.notification_counts;
|
||||
organization.value = data.organization;
|
||||
|
|
@ -43,6 +44,7 @@ export const useSessionStore = defineStore("session", () => {
|
|||
urls.value = data.urls;
|
||||
return data;
|
||||
} catch (e) {
|
||||
apiClient.setAuthenticated(false);
|
||||
error.value = e instanceof Error ? e.message : "an error ocurred";
|
||||
console.error("Error fetching user:", e);
|
||||
throw new Error(error.value);
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from "vue";
|
||||
import { apiClient } from "@/client";
|
||||
import { router } from "@/router";
|
||||
import { useSessionStore } from "@/store/session";
|
||||
|
||||
const session = useSessionStore();
|
||||
onMounted(() => {
|
||||
session.signout().then(() => {
|
||||
apiClient.setAuthenticated(false);
|
||||
router.push("/signin");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue