-
Notifications
You must be signed in to change notification settings - Fork 8
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
회원가입 / 로그인 페이지 구현, 기능 구현 #284
회원가입 / 로그인 페이지 구현, 기능 구현 #284
Conversation
import { useCallback, useEffect } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { useLoginStateQuery } from '@/queries/authentication/useLoginStateQuery'; | ||
|
||
export const useCheckLoginState = () => { | ||
const { error, isError } = useLoginStateQuery(); | ||
const navigate = useNavigate(); | ||
|
||
const handleLoginNavigate = useCallback(() => { | ||
navigate('/login'); | ||
}, [navigate]); | ||
|
||
useEffect(() => { | ||
if (isError) { | ||
alert(error.message); | ||
handleLoginNavigate(); | ||
} | ||
}, [error, isError, handleLoginNavigate]); | ||
}; |
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.
접근 권한을 제어하는 다른 방법도 있더라구요! 링크 첨부해요!
이와 같이 router.ts
에서 설정하면 각 페이지에서 인가 여부를 판단하지 않아도 됩니다!
https://github.com/noveogroup-amorgunov/nukeapp/blob/main/src/app/appRouter.tsx
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.
이전 PR 리뷰 참고 부탁드립니다.
새로 반영된 사항들은 오늘 중간 컴펌 끝나고 마저 리뷰 달게요!
⚡️ 관련 이슈
#197, #198
📍주요 변경 사항
localStorage 같은 경우, 만약 백엔드가 Basic token + httponly 쿠키로 구현이 된다면 필요 없어보입니다. JWT 토큰을 가정하고 구현된 부분입니다.
user 정보 관리
🎸기타