Skip to content

Commit 99f4cf7

Browse files
luizhf42gustavosbarreto
authored andcommitted
fix(ui): fix account creation flow when accepting invite
1 parent 5d163ef commit 99f4cf7

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

ui/src/components/Account/AccountCreated.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ const handleAction = async () => {
109109
else await redirect();
110110
};
111111
112-
watch(showMessage, (newValue) => {
112+
watch(showMessage, async (newValue) => {
113113
if (newValue && props.messageKind === "sig") {
114-
authStore.token = token.value as string;
114+
await authStore.loginWithToken(token.value || "");
115115
setTimeout(() => { void redirect(); }, 5000);
116116
}
117117
});

ui/src/router/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import useLayoutStore, { Layout } from "@/store/modules/layout";
88
import useNamespacesStore from "@/store/modules/namespaces";
99
import useUsersStore from "@/store/modules/users";
1010
import useWebEndpointsStore from "@/store/modules/web_endpoints";
11+
import { computed } from "vue";
1112

1213
export const handleAcceptInvite = async (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => {
1314
const namespacesStore = useNamespacesStore();
@@ -18,7 +19,7 @@ export const handleAcceptInvite = async (to: RouteLocationNormalized, from: Rout
1819
sig: (to.query.sig || from.query.sig) as string,
1920
});
2021
const { userStatus } = namespacesStore;
21-
const { isLoggedIn } = useAuthStore();
22+
const isLoggedIn = computed(() => useAuthStore().isLoggedIn);
2223

2324
switch (userStatus) {
2425
case "invited":
@@ -34,7 +35,7 @@ export const handleAcceptInvite = async (to: RouteLocationNormalized, from: Rout
3435
});
3536
return;
3637
case "confirmed":
37-
if (!isLoggedIn) {
38+
if (!isLoggedIn.value) {
3839
next({
3940
path: "/login",
4041
query: { redirect: "/accept-invite", ...to.query },
@@ -554,10 +555,10 @@ export const router = createRouter({
554555
router.beforeEach(
555556
async (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => {
556557
await useUsersStore().fetchSystemInfo();
557-
const { isLoggedIn } = useAuthStore();
558+
const isLoggedIn = computed(() => useAuthStore().isLoggedIn);
558559
const requiresAuth = to.meta.requiresAuth ?? true;
559560

560-
if (!isLoggedIn && requiresAuth) return next({
561+
if (!isLoggedIn.value && requiresAuth) return next({
561562
name: "Login",
562563
query: { redirect: to.fullPath },
563564
});

ui/src/store/modules/users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const useUsersStore = defineStore("users", () => {
1414
const { data: user } = await usersApi.signUp(data) as unknown as { data: { token?: string } };
1515

1616
if (!user.token) return false;
17-
1817
useAuthStore().persistAuth(user);
18+
signUpToken.value = user.token;
1919
return user.token;
2020
};
2121

0 commit comments

Comments
 (0)