diff --git a/frontend/src/components/pages/login/index.tsx b/frontend/src/components/pages/login/index.tsx index 8000b48..8d125c3 100644 --- a/frontend/src/components/pages/login/index.tsx +++ b/frontend/src/components/pages/login/index.tsx @@ -22,12 +22,11 @@ const LoginPage = () => { }); useEffect(() => { - if (!loginMutation.data) return; - if (Object.hasOwn(loginMutation.data.login, "message")) { - setSubmitError(loginMutation.data.login.message); + if (!loginMutation.data) { return; - } - if (Object.hasOwn(loginMutation.data.login, "token")) { + } else if (loginMutation.data.login.__typename == "CommonError") { + setSubmitError(loginMutation.data.login.message); + } else if (loginMutation.data.login.__typename == "AuthSuccess") { localStorage.setItem("token", loginMutation.data.login.token); navigator("/services"); } diff --git a/frontend/src/queries/auth.graphql b/frontend/src/queries/auth.graphql index 3233b15..8d3c4b2 100644 --- a/frontend/src/queries/auth.graphql +++ b/frontend/src/queries/auth.graphql @@ -1,5 +1,6 @@ mutation Login($credentials: LoginInput!) { login(body: $credentials) { + __typename ... on AuthSuccess { user { name