From ba025b8fd85ed8e9f8f40452bf2f05c52cb123a0 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 30 Dec 2022 05:19:12 -0800 Subject: [PATCH] Set user token after login and signup --- components/LoginModal/index.tsx | 4 ++++ components/SignupModal/index.tsx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/components/LoginModal/index.tsx b/components/LoginModal/index.tsx index 0ad5a49b..02753844 100644 --- a/components/LoginModal/index.tsx +++ b/components/LoginModal/index.tsx @@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next' import axios, { AxiosError, AxiosResponse } from 'axios' import api from '~utils/api' +import setUserToken from '~utils/setUserToken' import { accountState } from '~utils/accountState' import Button from '~components/Button' @@ -137,6 +138,9 @@ const LoginModal = () => { } setCookie('account', cookieObj, { path: '/' }) + + // Set Axios default headers + setUserToken() } function storeUserInfo(response: AxiosResponse) { diff --git a/components/SignupModal/index.tsx b/components/SignupModal/index.tsx index 8288d4a7..505695fa 100644 --- a/components/SignupModal/index.tsx +++ b/components/SignupModal/index.tsx @@ -5,6 +5,7 @@ import { useTranslation } from 'next-i18next' import { AxiosResponse } from 'axios' import api from '~utils/api' +import setUserToken from '~utils/setUserToken' import { accountState } from '~utils/accountState' import Button from '~components/Button' @@ -94,6 +95,9 @@ const SignupModal = (props: Props) => { } setCookie('account', cookieObj, { path: '/' }) + + // Set Axios default headers + setUserToken() } function fetchUserInfo(id: string) {