Skip to content

Commit

Permalink
fix: modified auth logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonski committed Jul 20, 2023
1 parent 1874cff commit b619b0b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.20.1
6 changes: 5 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ function App() {
useEffect(() => {
verify()
.then(({ data: { data } }) => {
setUserState(data.role);
if (data.role.toLowerCase() === 'admin') {
setUserState('admin');
} else if (data.role.toLowerCase() === 'client') {
setUserState('client');
}
})
.catch(() => setUserState(false));
window.localStorage.removeItem('userState');
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function SignIn() {
//이미 로그인되어있다면 redirect시킴
const verifyUser = () => {
verify().then(({ data: { data } }) => {
if (data.role === "Admin") {
if (data.role.toLowerCase() === "admin") {
navigate("/admin");
setUserState("admin");
} //admin 유저일 경우
Expand Down

0 comments on commit b619b0b

Please sign in to comment.