Skip to content

Commit 88087ab

Browse files
committed
fix(web): redirect to /login after sign out
MainToolbar and NavBar were calling logout() without navigating away, leaving the user on an authenticated-only page with cleared content.
1 parent c3392e4 commit 88087ab

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

new-deepnotes/apps/web/src/components/NavBar.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { RouterLink } from "vue-router";
2+
import { RouterLink, useRouter } from "vue-router";
33
44
import { Button } from "@/components/ui/button";
55
import { useSession } from "@/features/auth/useSession";
@@ -8,11 +8,13 @@ import ThemeSwitcher from "@/features/theme/ThemeSwitcher.vue";
88
import { isDark } from "@/features/theme/useThemePreference";
99
1010
const { isAuthenticated, bootstrapped, loading, logout } = useSession();
11+
const router = useRouter();
1112
1213
const marketingUrl = import.meta.env.VITE_MARKETING_APP_URL?.trim().replace(/\/$/, "") || "https://deepnotes.app";
1314
1415
async function onLogout() {
1516
await logout();
17+
await router.push("/login");
1618
}
1719
</script>
1820

new-deepnotes/apps/web/src/features/spatial/MainToolbar.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import { afterEach, describe, expect, it, vi } from "vitest";
22
import { mount } from "@vue/test-utils";
33
import { defineComponent, h, ref } from "vue";
44

5+
const mockPush = vi.fn();
6+
57
vi.mock("vue-router", () => ({
68
RouterLink: defineComponent({
79
props: ["to"],
810
setup(props, { slots }) {
911
return () => h("a", { "data-testid": "router-link", "data-to": props.to }, slots);
1012
},
1113
}),
14+
useRouter: () => ({
15+
push: mockPush,
16+
}),
1217
}));
1318

1419
vi.mock("@/features/auth/useSession", () => ({

new-deepnotes/apps/web/src/features/spatial/MainToolbar.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { RouterLink } from "vue-router";
2+
import { RouterLink, useRouter } from "vue-router";
33
44
import { Button } from "@/components/ui/button";
55
import { useSession } from "@/features/auth/useSession";
@@ -24,13 +24,15 @@ const emit = defineEmits<{
2424
}>();
2525
2626
const { isAuthenticated, bootstrapped, loading, logout } = useSession();
27+
const router = useRouter();
2728
2829
const marketingUrl =
2930
import.meta.env.VITE_MARKETING_APP_URL?.trim().replace(/\/+$/, "") ||
3031
"https://deepnotes.app";
3132
3233
async function onLogout() {
3334
await logout();
35+
await router.push("/login");
3436
}
3537
</script>
3638

0 commit comments

Comments
 (0)