File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
packages/devextreme-cli/src/templates/nextjs/application/src Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -16,16 +16,25 @@ async function _DEMO_logIn() {
1616 return await _DEMO_logIn ( ) ;
1717
1818 // In production, you will need to redirect unauthorized users
19- // return NextResponse.redirect(new URL('/login', req.nextUrl))
19+ // return NextResponse.redirect(new URL('/auth/ login', req.nextUrl))
2020}
2121
2222export default async function middleware ( req < %= #isTypeScript% > : NextRequest < %= / i s T y p e S c r i p t % > ) {
2323 const path = req . nextUrl . pathname ;
24-
24+
25+ if ( ! isProtectedRoute ( path ) ) {
26+ return NextResponse . next ( ) ;
27+ }
28+
2529 const cookie = ( await cookies ( ) ) . get ( 'session' ) ?. value ;
30+
31+ if ( ! cookie ) {
32+ return await redirectUnauthorized ( req ) ;
33+ }
34+
2635 const session = await decrypt ( cookie ) ;
27-
28- if ( isProtectedRoute ( path ) && ! session ?. userId ) {
36+
37+ if ( ! session ?. userId ) {
2938 return await redirectUnauthorized ( req ) ;
3039 }
3140
You can’t perform that action at this time.
0 commit comments