-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moves authenticated pages under /auth route
- Loading branch information
Showing
27 changed files
with
140 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
import cx from 'classnames'; | ||
import { PropsWithChildren } from 'react'; | ||
|
||
import { useRouter } from 'next/router'; | ||
import { usePathname } from 'next/navigation'; | ||
|
||
import { cn } from 'lib/utils'; | ||
|
||
import Footer from 'containers/footer'; | ||
import Header from 'containers/header'; | ||
|
||
type ApplicationLayoutProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const ApplicationLayout: React.FC<ApplicationLayoutProps> = (props: ApplicationLayoutProps) => { | ||
const { children } = props; | ||
const { pathname } = useRouter(); | ||
export default function ApplicationLayout({ children }: PropsWithChildren) { | ||
const pathname = usePathname(); | ||
const isAuthRoute = pathname.includes('/auth'); | ||
|
||
return ( | ||
<div | ||
className={cx({ | ||
className={cn({ | ||
'flex flex-col lg:min-h-screen': true, | ||
'bg-grey-60': pathname.includes('/auth'), | ||
'bg-grey-60': isAuthRoute, | ||
})} | ||
> | ||
<Header /> | ||
|
||
<main className="flex flex-col grow"> | ||
{/* Content */} | ||
<main | ||
className={cn({ | ||
'flex flex-col grow': true, | ||
'bg-grey-60': isAuthRoute, | ||
})} | ||
> | ||
{children} | ||
</main> | ||
|
||
<Footer /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ApplicationLayout; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
export { default } from 'next-auth/middleware'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export const config = { | ||
matcher: ['/my-details/:path*', '/my-projects/:path*', '/my-investments/:path*'], | ||
import { NextRequestWithAuth, withAuth } from 'next-auth/middleware'; | ||
|
||
const PRIVATE_PAGES = /^(\/auth(?!\/signin|\/signup|\/forgot-password))/; | ||
|
||
export const isPrivatePath = (pathname: string) => { | ||
return PRIVATE_PAGES.test(pathname); | ||
}; | ||
|
||
export default function middleware(req: NextRequestWithAuth) { | ||
if (isPrivatePath(req.nextUrl.pathname)) { | ||
return withAuth(req, { | ||
pages: { | ||
signIn: '/auth/signin', | ||
}, | ||
}); | ||
} | ||
|
||
return NextResponse.next(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
client/src/pages/my-projects/new.tsx → client/src/pages/auth/projects/new.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.