Skip to content

Commit 9897719

Browse files
committed
added vercel.json
1 parent 454d685 commit 9897719

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

src/app/auth/AuthGuard.jsx

+34-35
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import useAuth from 'app/hooks/useAuth'
2-
import { Navigate, useLocation } from 'react-router-dom'
1+
import useAuth from 'app/hooks/useAuth';
2+
// import { flat } from 'app/utils/utils';
3+
import { Navigate, useLocation } from 'react-router-dom';
4+
// import AllPages from '../routes';
35

4-
// const getUserRoleAuthStatus = (pathname, user, routes) => {
6+
// const userHasPermission = (pathname, user, routes) => {
57
// if (!user) {
68
// return false;
79
// }
@@ -13,35 +15,32 @@ import { Navigate, useLocation } from 'react-router-dom'
1315
// };
1416

1517
const AuthGuard = ({ children }) => {
16-
const { isAuthenticated } = useAuth()
17-
const { pathname } = useLocation()
18-
// const flatRoutes = flat(routes);
19-
20-
// const isUserRoleAuthenticated = getUserRoleAuthStatus(
21-
// pathname,
22-
// user,
23-
// flatRoutes
24-
// )
25-
// let authenticated = isAuthenticated && isUserRoleAuthenticated
26-
27-
// IF YOU NEED ROLE BASED AUTHENTICATION,
28-
// UNCOMMENT ABOVE TWO LINES, getUserRoleAuthStatus METHOD AND user VARIABLE
29-
// AND COMMENT OUT BELOW LINE
30-
// let location = useLocation()
31-
32-
return (
33-
<>
34-
{isAuthenticated ? (
35-
children
36-
) : (
37-
<Navigate
38-
replace
39-
to="/session/signin"
40-
state={{ from: pathname }}
41-
/>
42-
)}
43-
</>
44-
)
45-
}
46-
47-
export default AuthGuard
18+
let {
19+
isAuthenticated,
20+
// user
21+
} = useAuth();
22+
const { pathname } = useLocation();
23+
24+
// const routes = flat(AllPages);
25+
26+
// const hasPermission = userHasPermission(pathname, user, routes);
27+
// let authenticated = isAuthenticated && hasPermission;
28+
29+
// // IF YOU NEED ROLE BASED AUTHENTICATION,
30+
// // UNCOMMENT ABOVE LINES
31+
// // AND COMMENT OUT BELOW authenticated VARIABLE
32+
33+
let authenticated = isAuthenticated;
34+
35+
return (
36+
<>
37+
{authenticated ? (
38+
children
39+
) : (
40+
<Navigate replace to="/session/signin" state={{ from: pathname }} />
41+
)}
42+
</>
43+
);
44+
};
45+
46+
export default AuthGuard;

vercel.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"rewrites": [{ "source": "/(.*)", "destination": "/" }]
3+
}

0 commit comments

Comments
 (0)