Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 2ea6d25

Browse files
committed
changes
1 parent 449920e commit 2ea6d25

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

client/src/components/Protected/ProtectedRoute.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ import { useAuth } from '../../context/AuthContext.js'
66

77
function ProtectedRoute({ children }) {
88
const { user } = useAuth()
9-
const isDevMode = import.meta.env.VITE_APP_NODE_ENV === 'production'
9+
const isDevMode = import.meta.env.VITE_APP_NODE_ENV !== 'production'
10+
const isUserLogin = Boolean(user) || (isDevMode && Boolean(Cookies.get('token')))
1011

11-
const isUserLogin = user || Boolean(Cookies.get('token')) || isDevMode
12-
13-
if (isUserLogin) {
14-
return children
15-
} else {
16-
return <Navigate to="/login" replace />
17-
}
12+
return isUserLogin ? children : <Navigate to="/login" replace />
1813
}
1914

2015
ProtectedRoute.propTypes = {

0 commit comments

Comments
 (0)