fix: admin voit tous les projets, pas seulement les siens
- listAllProjects() pour les admins (sans filtre userId) - Les users normaux voient toujours uniquement leurs projets Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
51bb69eb88
commit
2b64dc25fb
2 changed files with 9 additions and 0 deletions
|
|
@ -88,6 +88,12 @@ export async function listProjects(userId: number) {
|
|||
return db.select().from(projects).where(eq(projects.userId, userId)).orderBy(desc(projects.createdAt));
|
||||
}
|
||||
|
||||
export async function listAllProjects() {
|
||||
const db = await getDb();
|
||||
if (!db) return [];
|
||||
return db.select().from(projects).orderBy(desc(projects.createdAt));
|
||||
}
|
||||
|
||||
export async function updateProject(id: number, data: Partial<InsertProject>) {
|
||||
const db = await getDb();
|
||||
if (!db) return;
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@ export const appRouter = router({
|
|||
// ============ PROJECTS ============
|
||||
projects: router({
|
||||
list: protectedProcedure.query(async ({ ctx }) => {
|
||||
if (ctx.user.role === "admin") {
|
||||
return db.listAllProjects();
|
||||
}
|
||||
return db.listProjects(ctx.user.id);
|
||||
}),
|
||||
get: protectedProcedure
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue