Fix issues with storing access token after signup
This commit is contained in:
parent
98f93406b7
commit
0f0c99e8bf
2 changed files with 9 additions and 7 deletions
|
|
@ -72,11 +72,11 @@ const SignupModal = (props: Props) => {
|
||||||
|
|
||||||
function storeCookieInfo(response: AxiosResponse) {
|
function storeCookieInfo(response: AxiosResponse) {
|
||||||
const user = response.data.user
|
const user = response.data.user
|
||||||
|
|
||||||
const cookieObj = {
|
const cookieObj = {
|
||||||
user_id: user.id,
|
user_id: user.user_id,
|
||||||
username: user.username,
|
username: user.username,
|
||||||
access_token: response.data.access_token
|
access_token: user.token
|
||||||
}
|
}
|
||||||
|
|
||||||
setCookies('account', cookieObj, { path: '/'})
|
setCookies('account', cookieObj, { path: '/'})
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,11 @@ const WeaponGrid = (props: Props) => {
|
||||||
const numWeapons: number = 9
|
const numWeapons: number = 9
|
||||||
|
|
||||||
// Cookies
|
// Cookies
|
||||||
const [cookies, _] = useCookies(['user'])
|
const [cookies] = useCookies(['account'])
|
||||||
const headers = (cookies.user != null) ? {
|
console.log(cookies)
|
||||||
|
const headers = (cookies.account != null) ? {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${cookies.user.access_token}`
|
'Authorization': `Bearer ${cookies.account.access_token}`
|
||||||
}
|
}
|
||||||
} : {}
|
} : {}
|
||||||
|
|
||||||
|
|
@ -56,7 +57,7 @@ const WeaponGrid = (props: Props) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!loading && !firstLoadComplete) {
|
if (!loading && !firstLoadComplete) {
|
||||||
// If user is logged in and matches
|
// If user is logged in and matches
|
||||||
if ((cookies.user && party.user && cookies.user.user_id === party.user.id) || props.new)
|
if ((cookies.account && party.user && cookies.account.user_id === party.user.id) || props.new)
|
||||||
appState.party.editable = true
|
appState.party.editable = true
|
||||||
else
|
else
|
||||||
appState.party.editable = false
|
appState.party.editable = false
|
||||||
|
|
@ -152,6 +153,7 @@ const WeaponGrid = (props: Props) => {
|
||||||
if (weapon.uncap.ulb) uncapLevel = 5
|
if (weapon.uncap.ulb) uncapLevel = 5
|
||||||
else if (weapon.uncap.flb) uncapLevel = 4
|
else if (weapon.uncap.flb) uncapLevel = 4
|
||||||
|
|
||||||
|
console.log(headers)
|
||||||
return await api.endpoints.weapons.create({
|
return await api.endpoints.weapons.create({
|
||||||
'weapon': {
|
'weapon': {
|
||||||
'party_id': partyId,
|
'party_id': partyId,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue