-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4200 from systeminit/redirect-to-default-workspace
feat(auth-portal): Redirect to the default workspace on login
- Loading branch information
Showing
4 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<template><div>Redirect to default workspace</div></template> | ||
|
||
<script setup lang="ts"> | ||
import { computed, onMounted } from "vue"; | ||
import { useRouter } from "vue-router"; | ||
import { useWorkspacesStore } from "@/store/workspaces.store"; | ||
import { useAuthStore } from "@/store/auth.store"; | ||
import { API_HTTP_URL } from "@/store/api"; | ||
const authStore = useAuthStore(); | ||
const router = useRouter(); | ||
const workspacesStore = useWorkspacesStore(); | ||
const defaultWorkspace = computed(() => workspacesStore.defaultWorkspace); | ||
onMounted(async () => { | ||
if (import.meta.env.SSR) return; | ||
if (!authStore.userIsLoggedIn) return; | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
await workspacesStore.LOAD_WORKSPACES(); | ||
if (defaultWorkspace.value) { | ||
window.location.href = `${API_HTTP_URL}/workspaces/${defaultWorkspace.value.id}/go`; | ||
} else { | ||
await router.push({ | ||
name: "workspaces", | ||
}); | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters