Loan Laux 8f260d66e7
implement login
Signed-off-by: Loan Laux <loan@outgrow.io>
2021-04-23 20:35:14 +04:00

26 lines
547 B
TypeScript

import Cookies, { CookieAttributes } from 'js-cookie'
import {
REACTION_COOKIE_EXPIRE,
REACTION_CUSTOMER_TOKEN_COOKIE,
} from '../const'
export const getCustomerToken = () =>
Cookies.get(REACTION_CUSTOMER_TOKEN_COOKIE)
export const setCustomerToken = (
token: string | null,
options?: CookieAttributes
) => {
if (!token) {
Cookies.remove(REACTION_CUSTOMER_TOKEN_COOKIE)
} else {
Cookies.set(
REACTION_CUSTOMER_TOKEN_COOKIE,
token,
options ?? {
expires: REACTION_COOKIE_EXPIRE,
}
)
}
}