From e79821bdae5d17deaf474c905528be79962d51f7 Mon Sep 17 00:00:00 2001 From: SushantJadhav Date: Thu, 26 Aug 2021 08:17:44 +0530 Subject: [PATCH] Refactored login.ts --- framework/kibocommerce/api/endpoints/login/login.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/framework/kibocommerce/api/endpoints/login/login.ts b/framework/kibocommerce/api/endpoints/login/login.ts index eb882d998..14acb62f6 100644 --- a/framework/kibocommerce/api/endpoints/login/login.ts +++ b/framework/kibocommerce/api/endpoints/login/login.ts @@ -25,16 +25,17 @@ const login: LoginEndpoint['handlers']['login'] = async ({ } try { - response = await config.fetch(loginMutation, { variables: { loginInput : { username: email, password }}}) + const variables = { loginInput : { username: email, password }}; + response = await config.fetch(loginMutation, { variables: variables}) const { account: token } = response.data; - + const authCookie = prepareSetCookie( config.customerCookie, JSON.stringify(token), token.accessTokenExpiration ? { expires: new Date(token.accessTokenExpiration) }: {}, ) setCookies(res, [authCookie]) - + } catch (error) { // Check if the email and password didn't match an existing account if (