Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
survey
Commits
9388110e
Commit
9388110e
authored
Jul 07, 2022
by
Yoon, Daeki
😅
Browse files
RequireAuth 컴포넌트 추가
parent
4ff854ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/src/auth/RequireAuth.tsx
0 → 100644
View file @
9388110e
import
React
,
{
FC
}
from
"
react
"
;
import
{
Navigate
,
useLocation
}
from
"
react-router-dom
"
;
import
{
useAuth
}
from
"
./auth.context
"
;
export
const
RequireAuth
:
FC
<
{
children
:
JSX
.
Element
}
>
=
({
children
})
=>
{
const
{
user
}
=
useAuth
();
const
location
=
useLocation
();
if
(
!
user
.
isLoggedIn
)
{
return
(
<
Navigate
to
=
{
"
/login
"
}
state
=
{
{
from
:
location
.
pathname
}
}
replace
/>
);
}
return
children
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment