Added basic validation for requests
This commit is contained in:
@@ -6,7 +6,7 @@ export async function GET(req: Request) {
|
||||
try {
|
||||
const user = await fetchUser(req)
|
||||
if (!user || user.role != "ADMIN") {
|
||||
return new NextResponse("Unauthorized", { status: 401 });
|
||||
return NextResponse.json({ message: 'Unauthorized.', error: null, value: null }, { status: 401 });
|
||||
}
|
||||
|
||||
const { searchParams } = new URL(req.url)
|
||||
@@ -36,6 +36,6 @@ export async function GET(req: Request) {
|
||||
return NextResponse.json(users)
|
||||
} catch (error) {
|
||||
console.log("[USERS]", error);
|
||||
return new NextResponse("Internal Error", { status: 500 });
|
||||
return NextResponse.json({ message: 'Something went wrong', error: error, value: null }, { status: 500 })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user