saleor: refine the auth process

This commit is contained in:
Zaiste
2021-05-11 14:27:30 +02:00
parent 85d203e85c
commit e98a9f4d6f
12 changed files with 78 additions and 101 deletions

View File

@@ -1,7 +1,7 @@
import useCustomer, { UseCustomer } from '@commerce/customer/use-customer'
import { Customer } from '@commerce/types'
import { SWRHook } from '@commerce/utils/types'
import { getCustomerQuery, getCustomerToken } from '../utils'
import { getCustomerQuery, getCSRFToken } from '../utils'
export default useCustomer as UseCustomer<typeof handler>
@@ -12,7 +12,7 @@ export const handler: SWRHook<Customer | null> = {
async fetcher({ options, fetch }) {
const data = await fetch<any | null>({
...options,
variables: { customerAccessToken: getCustomerToken() },
variables: { customerAccessToken: getCSRFToken() },
})
return data.customer ?? null
},