Add base admin interface
This commit is contained in:
1 parent
d769c3943c
commit
388ff394c7
25 files changed
+905
-24
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import prisma from '../../lib/prisma';
|
||||
import { getSession } from 'next-auth/client';
|
||||
|
||||
export default async function handler(req, res) {
|
||||
if (req.method === 'GET') {
|
||||
// Check that user is authenticated
|
||||
const session = await getSession({req: req});
|
||||
|
||||
if (!session) { res.status(401).json({message: 'You must be logged in to do this'}); return; }
|
||||
|
||||
// TODO: Add user ID so filtering works properly. User object does not include ID currently.
|
||||
|
||||
const credentials = await prisma.credential.findMany({
|
||||
where: {
|
||||
userId: session.user.id,
|
||||
},
|
||||
select: {
|
||||
type: true
|
||||
}
|
||||
});
|
||||
|
||||
res.status(200).json(credentials);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user