Login/logout process.

This commit is contained in:
Mike Cao 2020-07-25 16:31:07 -07:00
parent 0f0b1e39e7
commit f947c7770b
10 changed files with 91 additions and 58 deletions

27
pages/logout.js Normal file
View file

@ -0,0 +1,27 @@
import React from 'react';
import { serialize } from 'cookie';
import Layout from 'components/Layout';
export default function LogoutPage() {
return (
<Layout title="Logout">
<h2>You've successfully logged out..</h2>
</Layout>
);
}
export async function getServerSideProps({ res }) {
const cookie = serialize('umami.auth', '', {
path: '/',
httpOnly: true,
maxAge: 0,
});
res.statusCode = 303;
res.setHeader('Set-Cookie', [cookie]);
res.setHeader('Location', '/login');
res.end();
return { props: {} };
}