move login and add logout

This commit is contained in:
Thomas Ruoff
2021-06-16 23:29:12 +02:00
parent b6a1e45fcf
commit 9024310ce0
7 changed files with 44 additions and 15 deletions

16
pages/api/logout.ts Normal file
View File

@@ -0,0 +1,16 @@
import withSession from '../../lib/session'
async function loginHandler(req: any, res: any): Promise<void> {
const { method } = req
switch (method) {
case 'POST':
req.session.destroy()
res.json({ message: 'Logged out' })
break
default:
res.setHeader('Allow', ['POST'])
res.status(405).end(`Method ${method} Not Allowed`)
}
}
export default withSession(loginHandler)