mirror of
https://github.com/vercel/commerce.git
synced 2025-07-13 07:51:26 +00:00
Refactored login.ts
This commit is contained in:
parent
a122d68a2c
commit
e79821bdae
@ -25,16 +25,17 @@ const login: LoginEndpoint['handlers']['login'] = async ({
|
|||||||
}
|
}
|
||||||
try {
|
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 { account: token } = response.data;
|
||||||
|
|
||||||
const authCookie = prepareSetCookie(
|
const authCookie = prepareSetCookie(
|
||||||
config.customerCookie,
|
config.customerCookie,
|
||||||
JSON.stringify(token),
|
JSON.stringify(token),
|
||||||
token.accessTokenExpiration ? { expires: new Date(token.accessTokenExpiration) }: {},
|
token.accessTokenExpiration ? { expires: new Date(token.accessTokenExpiration) }: {},
|
||||||
)
|
)
|
||||||
setCookies(res, [authCookie])
|
setCookies(res, [authCookie])
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Check if the email and password didn't match an existing account
|
// Check if the email and password didn't match an existing account
|
||||||
if (
|
if (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user