-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
로그인 상태/라운지 참여여부 #114
base: develop
Are you sure you want to change the base?
로그인 상태/라운지 참여여부 #114
Conversation
src/pages/lounge/index.tsx
Outdated
|
||
// 로그인 하지 않은 상태로 라운지 진입시 | ||
useEffect(() => { | ||
if (!getCookie('jwt')) Router.push('/sign-in'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
검증은 서버에서 하는중일듯?
src/pages/lounge/index.tsx
Outdated
const statusVerify = async () => { | ||
try { | ||
// 내가 소속된 라운지 리스트 | ||
const loungeList = await Axios.get(`https://api.liontown.city/api/lounges`, { | ||
withCredentials: true, | ||
}); | ||
// 선택한 라운지 정보 -> {id} 부분에 임시로 값 넣음 | ||
const selectLounge = await Axios.get(`https://api.liontown.city/api/lounges/sgIG8L`, { | ||
withCredentials: true, | ||
}); | ||
// console.log(selectLounge.data.data.roomData); | ||
// 내가 소속된 라운지 리스트명과 선택한 라운지가 같지 않을 때 | ||
// 혹은 해당 라운지가 없는 경우 라운지 생성페이지로 보내기 | ||
if ( | ||
loungeList.data.data[0].name !== selectLounge.data.data.loungeName.name || | ||
selectLounge.status === 404 | ||
) { | ||
useRouter.push('/lounge-select'); | ||
setTimeout(() => returnLoungeSelect(), 2000); | ||
} | ||
} catch (err) { | ||
// console.log 없앨 예정 .. | ||
console.log('error'); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get 요청은 리액트 쿼리를 써주세요
api 패치를 한번에 두 개를 하는데 이 둘을 동기적으로 다룰 것이 아니라면 분리해주세요
selectLounge.status === 404 | ||
) { | ||
useRouter.push('/lounge-select'); | ||
setTimeout(() => returnLoungeSelect(), 2000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clear함수가 필요해보여요~
useEffect(() => { | ||
if (getCookie('jwt')) { | ||
router.push('/sign-in'); | ||
returnMessage(); | ||
} else { | ||
statusVerify(); | ||
} | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
httpOnly 설정으로 인해 프론트에서 쿠키 조작 불가합니다 axios나 리액트 쿼리에서 에러 핸들러로 로그인 검증 해주세요~
No description provided.