revert fb8e77bb68
Local Build and Deploy / deploy (push) Successful in 1m11s
Local Build and Deploy / deploy (push) Successful in 1m11s
revert style: clean up code with prettier and eslint
This commit is contained in:
1 parent
27de078f54
commit
e85e4d74ea
378 files changed
+20710
-22428
No files matched your search
@@ -1,25 +1,23 @@
|
||||
import { revalidateTag } from "next/cache";
|
||||
import { NextResponse } from "next/server";
|
||||
import { withAdmin } from "@/lib/api-handler";
|
||||
import { apiError } from "@/lib/api-response";
|
||||
import { PERMS } from "@/lib/permissions";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { revalidateTag } from 'next/cache'
|
||||
import { NextResponse } from 'next/server'
|
||||
import { withAdmin } from '@/lib/api-handler'
|
||||
import { apiError } from '@/lib/api-response'
|
||||
import { PERMS } from '@/lib/permissions'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
|
||||
export const POST = withAdmin({ permission: PERMS.PERMISSIONS_MANAGE }, async (request) => {
|
||||
const body = await request.json();
|
||||
const userId = Number(body.userId);
|
||||
const roleId = Number(body.roleId);
|
||||
const body = await request.json()
|
||||
const userId = Number(body.userId)
|
||||
const roleId = Number(body.roleId)
|
||||
if (!Number.isInteger(userId) || userId <= 0 || !Number.isInteger(roleId) || roleId <= 0) {
|
||||
return apiError("Valid userId and roleId required", 400);
|
||||
return apiError('Valid userId and roleId required', 400)
|
||||
}
|
||||
if (body.action === "remove") {
|
||||
await prisma.aclModelRole.deleteMany({ where: { modelType: "User", modelId: userId, roleId } });
|
||||
if (body.action === 'remove') {
|
||||
await prisma.aclModelRole.deleteMany({ where: { modelType: 'User', modelId: userId, roleId } })
|
||||
} else {
|
||||
const existing = await prisma.aclModelRole.findFirst({
|
||||
where: { modelType: "User", modelId: userId, roleId },
|
||||
});
|
||||
if (!existing) await prisma.aclModelRole.create({ data: { modelType: "User", modelId: userId, roleId } });
|
||||
const existing = await prisma.aclModelRole.findFirst({ where: { modelType: 'User', modelId: userId, roleId } })
|
||||
if (!existing) await prisma.aclModelRole.create({ data: { modelType: 'User', modelId: userId, roleId } })
|
||||
}
|
||||
revalidateTag("permissions", { expire: 0 });
|
||||
return NextResponse.json({ success: true });
|
||||
});
|
||||
revalidateTag('permissions', { expire: 0 })
|
||||
return NextResponse.json({ success: true })
|
||||
})
|
||||
Reference in new issue
Block a user