diff options
Diffstat (limited to 'src/common/components/Authenticated')
| -rw-r--r-- | src/common/components/Authenticated/index.tsx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common/components/Authenticated/index.tsx b/src/common/components/Authenticated/index.tsx new file mode 100644 index 0000000..cf7086e --- /dev/null +++ b/src/common/components/Authenticated/index.tsx @@ -0,0 +1,14 @@ +import { cookies } from 'next/headers' +import { redirect } from 'next/navigation' +import React from 'react' + +const Authenticated = ({ children }: { children: React.ReactNode }) => { + const credentialStr = cookies().get('credential')?.value + const credential: Credential | null = credentialStr ? JSON.parse(credentialStr) : null + + if (!credential) redirect('/login') + + return children +} + +export default Authenticated
\ No newline at end of file |
