-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #327 from Jaymyong66/refactor/authState
로그인 상태에 따른 Routes 보호, frontend_cd 업데이트, 로그인/회원가입 안내메시지 스타일 변경
- Loading branch information
Showing
10 changed files
with
102 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,8 @@ | |
|
||
### Environment Variable ### | ||
.env | ||
|
||
*.crt | ||
*.csr | ||
*.key | ||
*.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ReactNode } from 'react'; | ||
import { Navigate } from 'react-router-dom'; | ||
|
||
import { ToastContext } from '@/context/ToastContext'; | ||
import { useAuth } from '@/hooks/authentication/useAuth'; | ||
import useCustomContext from '@/hooks/utils/useCustomContext'; | ||
|
||
type AuthGuardProps = { | ||
children: ReactNode; | ||
}; | ||
|
||
const AuthGuard = ({ children }: AuthGuardProps) => { | ||
const { isLogin } = useAuth(); | ||
const { infoAlert } = useCustomContext(ToastContext); | ||
|
||
if (isLogin) { | ||
infoAlert('이미 로그인된 사용자입니다.'); | ||
|
||
return <Navigate to='/' />; | ||
} | ||
|
||
return children; | ||
}; | ||
|
||
export default AuthGuard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ReactNode } from 'react'; | ||
import { Navigate } from 'react-router-dom'; | ||
|
||
import { ToastContext } from '@/context/ToastContext'; | ||
import { useAuth } from '@/hooks/authentication/useAuth'; | ||
import useCustomContext from '@/hooks/utils/useCustomContext'; | ||
|
||
type GuestGuardProps = { | ||
children: ReactNode; | ||
}; | ||
|
||
const GuestGuard = ({ children }: GuestGuardProps) => { | ||
const { isLogin } = useAuth(); | ||
const { infoAlert } = useCustomContext(ToastContext); | ||
|
||
if (!isLogin) { | ||
infoAlert('로그인을 해주세요.'); | ||
|
||
return <Navigate to='/login' />; | ||
} | ||
|
||
return children; | ||
}; | ||
|
||
export default GuestGuard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters