Set user token after login and signup

This commit is contained in:
Justin Edmund 2022-12-30 05:19:12 -08:00
parent 18a998b1ed
commit ba025b8fd8
2 changed files with 8 additions and 0 deletions

View file

@ -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) {

View file

@ -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) {