From 805100a7aa143063d9432bddcab54dad39637527 Mon Sep 17 00:00:00 2001 From: Loan Laux Date: Wed, 28 Apr 2021 21:24:32 +0400 Subject: [PATCH] remove unused handleLogin util Signed-off-by: Loan Laux --- .../reactioncommerce/utils/handle-login.ts | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 framework/reactioncommerce/utils/handle-login.ts diff --git a/framework/reactioncommerce/utils/handle-login.ts b/framework/reactioncommerce/utils/handle-login.ts deleted file mode 100644 index 77b6873e3..000000000 --- a/framework/reactioncommerce/utils/handle-login.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { ValidationError } from '@commerce/utils/errors' -import { setCustomerToken } from './customer-token' - -const getErrorMessage = ({ - code, - message, -}: { - code: string - message: string -}) => { - switch (code) { - case 'UNIDENTIFIED_CUSTOMER': - message = 'Cannot find an account that matches the provided credentials' - break - } - return message -} - -const handleLogin = (data: any) => { - const response = data.customerAccessTokenCreate - const errors = response?.customerUserErrors - - if (errors && errors.length) { - throw new ValidationError({ - message: getErrorMessage(errors[0]), - }) - } - - const customerAccessToken = response?.customerAccessToken - const accessToken = customerAccessToken?.accessToken - - if (accessToken) { - setCustomerToken(accessToken) - } - - return customerAccessToken -} - -export default handleLogin