move admin api to /admin

This commit is contained in:
Thomas Ruoff
2020-11-02 22:44:27 +01:00
parent d440d0e07e
commit 19c8bc7be2
5 changed files with 127 additions and 10 deletions

View File

@@ -15,3 +15,12 @@ export default function withSession(handler: Handler) {
},
})
}
export const isAdminSession = function (req: any, res: any) {
const user = req?.session.get('user')
if (user && user.role === 'admin') {
return true
}
res.status(401).end('Your are unauthorized. Best to move along...')
return false
}