blob: cf7086ec5c406ab50bcba2c8b5cbb4cf686518b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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
|