import React from 'react'; import cookies from 'next-cookies'; import Layout from 'components/Layout'; import { verifySecureToken } from 'lib/crypto'; export default function Admin({ username }) { return (

You've successfully logged in as {username}.

); } export async function getServerSideProps(context) { const token = cookies(context)['umami.auth']; try { const payload = await verifySecureToken(token); return { props: { username: payload.username, }, }; } catch { const { res } = context; res.statusCode = 303; res.setHeader('Location', '/'); res.end(); } return { props: {} }; }