Skip to content
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

private router 처리하기 #116

Merged
merged 1 commit into from
Jan 20, 2022
Merged

private router 처리하기 #116

merged 1 commit into from
Jan 20, 2022

Conversation

SeojinSeojin
Copy link
Member

@SeojinSeojin SeojinSeojin commented Jan 19, 2022

⛓ Related Issues

📋 작업 내용

  • private router 만들기
  • 회원가입, 로그인, 렌딩, 마이페이지 제외하고 모두 private router 안에 가두기

📌 PR Point

  • 이제 로그인 안 하면 회원가입, 로그인, 렌딩, 마이페이지 제외하고 접근 못 한다!
  • 대신 한번이라도 로그인 했다면 다 접근할 수 있다!
  • 리라돔 v6에서는 Routes의 자식으로 Route가 아닌 친구를 둘 수가 없어서 이렇게 했읍니다.. 모든 스택오버플로우에서 이 방법밖에 없다고 함 ㅜㅜ

이 파일이 제일 중요함!

import { useLoginUser } from '@hooks/useLoginUser';
import { Navigate, Outlet } from 'react-router-dom';

function PrivateRoute() {
  const { isAuthenticated, isLoading } = useLoginUser();
  return isLoading ? <></> : isAuthenticated ? <Outlet /> : <Navigate to="/" />;
}

export default PrivateRoute;

🔬 Reference

@SeojinSeojin SeojinSeojin added the feature 🎄 기능 개발 label Jan 19, 2022
@SeojinSeojin SeojinSeojin self-assigned this Jan 19, 2022
@SeojinSeojin
Copy link
Member Author

울 웹쁜이 고생많았어 ! 여기서 미리보기로 보면서 쉬어~ 다른 웹쁜이들한테도 자랑해줘~

Copy link
Member

@100Gyeon 100Gyeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redirect가 사라진 게 충격이구만.. v6 써서 잘 만들었다 수고했엉 👍🏻👍🏻

Copy link
Member

@NamJwong NamJwong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.‌‌ ₍ᐢ๑- ˔ -ᐢ₎ ♡
_( っ / ̄ ̄ ̄/
(´  \/___/)
——————–
고 생 했 어 요 ♡

@SeojinSeojin SeojinSeojin merged commit 6ea14de into dev Jan 20, 2022
@SeojinSeojin SeojinSeojin deleted the feat/#111 branch January 20, 2022 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🎄 기능 개발
Projects
None yet
Development

Successfully merging this pull request may close these issues.

첫 접속 시 토큰으로 유저 초기화 API 누나쿵, Private Router 처리
4 participants