Refactored login.ts

This commit is contained in:
SushantJadhav 2021-08-26 08:17:44 +05:30
parent a122d68a2c
commit e79821bdae

View File

@ -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 (