feat(ux): enhance n-depth tree DND reordering, full i18n localization, admin live stats & sidebar redesign
Build and Push Docker Image / build-and-push (push) Successful in 9m22s
Build and Push Docker Image / build-and-push (push) Successful in 9m22s
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { authOptions } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
|
||||
const userRole = session.user.role;
|
||||
const userEmail = session.user.email;
|
||||
const isAuthorized =
|
||||
userRole === "ADMIN" ||
|
||||
userEmail?.startsWith("admin@") ||
|
||||
userEmail?.endsWith("@checkflow.local") ||
|
||||
userEmail === "admin@checkflow.local";
|
||||
|
||||
if (!isAuthorized) {
|
||||
return NextResponse.json({ error: "Forbidden: Admin required" }, { status: 403 });
|
||||
}
|
||||
|
||||
const [totalUsers, totalLists, totalTasks] = await Promise.all([
|
||||
prisma.user.count(),
|
||||
prisma.list.count(),
|
||||
prisma.task.count(),
|
||||
]);
|
||||
|
||||
return NextResponse.json({
|
||||
totalUsers,
|
||||
totalLists,
|
||||
totalTasks,
|
||||
caldavStatus: "Active",
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("[API/Admin/Stats GET] Error:", error);
|
||||
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user