From c918fa3443e53db69b9f61ef9fd7f1d293f127b7 Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Thu, 2 Apr 2026 15:33:54 +0700 Subject: [PATCH] Route new logins to profile until company card is filled --- app/composables/graphql/generated.ts | 10 ++++++++-- app/pages/login.vue | 10 ++++++++++ graphql/operations/auth/consume-login-token.graphql | 3 +++ graphql/operations/auth/verify-login-code.graphql | 3 +++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/composables/graphql/generated.ts b/app/composables/graphql/generated.ts index 051ef35..5624428 100644 --- a/app/composables/graphql/generated.ts +++ b/app/composables/graphql/generated.ts @@ -521,7 +521,7 @@ export type ConsumeLoginTokenMutationVariables = Exact<{ }>; -export type ConsumeLoginTokenMutation = { __typename?: 'Mutation', consumeLoginToken: { __typename?: 'AuthSession', accessToken: string, expiresAt: any, user: { __typename?: 'User', id: string, email: string, fullName: string, role: UserRole } } }; +export type ConsumeLoginTokenMutation = { __typename?: 'Mutation', consumeLoginToken: { __typename?: 'AuthSession', accessToken: string, expiresAt: any, user: { __typename?: 'User', id: string, email: string, fullName: string, role: UserRole, company?: { __typename?: 'Company', id: string } | null } } }; export type RegisterSelfMutationVariables = Exact<{ input: RegisterSelfInput; @@ -542,7 +542,7 @@ export type VerifyLoginCodeMutationVariables = Exact<{ }>; -export type VerifyLoginCodeMutation = { __typename?: 'Mutation', verifyLoginCode: { __typename?: 'AuthSession', accessToken: string, expiresAt: any, user: { __typename?: 'User', id: string, email: string, fullName: string, role: UserRole } } }; +export type VerifyLoginCodeMutation = { __typename?: 'Mutation', verifyLoginCode: { __typename?: 'AuthSession', accessToken: string, expiresAt: any, user: { __typename?: 'User', id: string, email: string, fullName: string, role: UserRole, company?: { __typename?: 'Company', id: string } | null } } }; export type ClientProductsQueryVariables = Exact<{ [key: string]: never; }>; @@ -621,6 +621,9 @@ export const ConsumeLoginTokenDocument = gql` email fullName role + company { + id + } } } } @@ -723,6 +726,9 @@ export const VerifyLoginCodeDocument = gql` email fullName role + company { + id + } } } } diff --git a/app/pages/login.vue b/app/pages/login.vue index ddb00ff..1498b94 100644 --- a/app/pages/login.vue +++ b/app/pages/login.vue @@ -50,6 +50,14 @@ const maxLoginUrl = computed(() => buildBotLoginUrl(maxBotUrl.value)); async function finalizeSession(accessToken: string) { authCookie.value = accessToken; +} + +async function navigateAfterLogin(user: { company?: { id: string } | null }) { + if (!user.company?.id) { + await navigateTo('/profile'); + return; + } + await navigateTo('/products'); } @@ -146,6 +154,7 @@ async function verifyCode() { } await finalizeSession(payload.accessToken); + await navigateAfterLogin(payload.user); } async function consumeLoginToken(loginToken: string) { @@ -160,6 +169,7 @@ async function consumeLoginToken(loginToken: string) { return; } await finalizeSession(payload.accessToken); + await navigateAfterLogin(payload.user); } function scheduleAutoRequest() { diff --git a/graphql/operations/auth/consume-login-token.graphql b/graphql/operations/auth/consume-login-token.graphql index ac32467..67a24a9 100644 --- a/graphql/operations/auth/consume-login-token.graphql +++ b/graphql/operations/auth/consume-login-token.graphql @@ -7,6 +7,9 @@ mutation ConsumeLoginToken($token: String!) { email fullName role + company { + id + } } } } diff --git a/graphql/operations/auth/verify-login-code.graphql b/graphql/operations/auth/verify-login-code.graphql index ec1baf6..3e3b323 100644 --- a/graphql/operations/auth/verify-login-code.graphql +++ b/graphql/operations/auth/verify-login-code.graphql @@ -7,6 +7,9 @@ mutation VerifyLoginCode($input: VerifyLoginCodeInput!) { email fullName role + company { + id + } } } }