Tentatively fix Login and Signup

There's probably more here, but I can at least log in right now
This commit is contained in:
Justin Edmund 2022-12-22 01:36:32 -08:00
parent e9b4f44fd6
commit 700a4d653c
2 changed files with 14 additions and 13 deletions

View file

@ -99,7 +99,7 @@ const LoginModal = (props: Props) => {
.login(body) .login(body)
.then((response) => { .then((response) => {
storeCookieInfo(response) storeCookieInfo(response)
return response.data.user.id return response.data.id
}) })
.then((id) => fetchUserInfo(id)) .then((id) => fetchUserInfo(id))
.then((infoResponse) => storeUserInfo(infoResponse)) .then((infoResponse) => storeUserInfo(infoResponse))
@ -111,7 +111,7 @@ const LoginModal = (props: Props) => {
} }
function storeCookieInfo(response: AxiosResponse) { function storeCookieInfo(response: AxiosResponse) {
const user = response.data.user const user = response.data
const cookieObj: AccountCookie = { const cookieObj: AccountCookie = {
userId: user.id, userId: user.id,
@ -123,11 +123,11 @@ const LoginModal = (props: Props) => {
} }
function storeUserInfo(response: AxiosResponse) { function storeUserInfo(response: AxiosResponse) {
const user = response.data.user const user = response.data
const cookieObj: UserCookie = { const cookieObj: UserCookie = {
picture: user.picture.picture, picture: user.avatar.picture,
element: user.picture.element, element: user.avatar.element,
language: user.language, language: user.language,
gender: user.gender, gender: user.gender,
} }
@ -137,8 +137,8 @@ const LoginModal = (props: Props) => {
accountState.account.user = { accountState.account.user = {
id: user.id, id: user.id,
username: user.username, username: user.username,
picture: user.picture.picture, picture: user.avatar.picture,
element: user.picture.element, element: user.avatar.element,
gender: user.gender, gender: user.gender,
} }

View file

@ -75,7 +75,7 @@ const SignupModal = (props: Props) => {
.create(body) .create(body)
.then((response) => { .then((response) => {
storeCookieInfo(response) storeCookieInfo(response)
return response.data.user.user_id return response.data.user_id
}) })
.then((id) => fetchUserInfo(id)) .then((id) => fetchUserInfo(id))
.then((infoResponse) => storeUserInfo(infoResponse)) .then((infoResponse) => storeUserInfo(infoResponse))
@ -98,11 +98,12 @@ const SignupModal = (props: Props) => {
} }
function storeUserInfo(response: AxiosResponse) { function storeUserInfo(response: AxiosResponse) {
const user = response.data.user const user = response.data
console.log(user)
const cookieObj: UserCookie = { const cookieObj: UserCookie = {
picture: user.picture.picture, picture: user.avatar.picture,
element: user.picture.element, element: user.avatar.element,
language: user.language, language: user.language,
gender: user.gender, gender: user.gender,
} }
@ -113,8 +114,8 @@ const SignupModal = (props: Props) => {
accountState.account.user = { accountState.account.user = {
id: user.id, id: user.id,
username: user.username, username: user.username,
picture: user.picture.picture, picture: user.avatar.picture,
element: user.picture.element, element: user.avatar.element,
gender: user.gender, gender: user.gender,
} }