diff --git a/src/tools/auth.ts b/src/tools/auth.ts index 075024f..6758784 100644 --- a/src/tools/auth.ts +++ b/src/tools/auth.ts @@ -31,8 +31,8 @@ const getAuthInfo: BaseTool> = { const statsQuery = await pgClient.query(` SELECT (SELECT COUNT(*) FROM users WHERE "deletedAt" IS NULL) as total_users, - (SELECT COUNT(*) FROM users WHERE "isAdmin" = true AND "deletedAt" IS NULL) as admin_users, - (SELECT COUNT(*) FROM users WHERE "isSuspended" = true) as suspended_users, + (SELECT COUNT(*) FROM users WHERE role = 'admin' AND "deletedAt" IS NULL) as admin_users, + (SELECT COUNT(*) FROM users WHERE "suspendedAt" IS NOT NULL) as suspended_users, (SELECT COUNT(*) FROM teams) as total_teams, (SELECT COUNT(*) FROM oauth_clients) as oauth_clients, (SELECT COUNT(*) FROM oauth_authentications) as oauth_authentications @@ -48,8 +48,8 @@ const getAuthInfo: BaseTool> = { u.email, u."lastActiveAt", u."lastSignedInAt", - u."isAdmin", - u."isSuspended" + u.role, + u."suspendedAt" FROM users u WHERE u."deletedAt" IS NULL ORDER BY u."lastActiveAt" DESC NULLS LAST diff --git a/src/tools/comments.ts b/src/tools/comments.ts index 5bfa926..14d6eb3 100644 --- a/src/tools/comments.ts +++ b/src/tools/comments.ts @@ -252,7 +252,7 @@ const createComment: BaseTool = { // Note: In real implementation, createdById should come from authentication context // For now, we'll get the first admin user const userQuery = await pgClient.query( - 'SELECT id FROM users WHERE "isAdmin" = true AND "deletedAt" IS NULL LIMIT 1' + `SELECT id FROM users WHERE role = 'admin' AND "deletedAt" IS NULL LIMIT 1` ); if (userQuery.rows.length === 0) { @@ -427,7 +427,7 @@ const resolveComment: BaseTool = { // Get first admin user as resolver const userQuery = await pgClient.query( - 'SELECT id FROM users WHERE "isAdmin" = true AND "deletedAt" IS NULL LIMIT 1' + `SELECT id FROM users WHERE role = 'admin' AND "deletedAt" IS NULL LIMIT 1` ); if (userQuery.rows.length === 0) { diff --git a/src/tools/documents.ts b/src/tools/documents.ts index a601a01..1ae1a34 100644 --- a/src/tools/documents.ts +++ b/src/tools/documents.ts @@ -217,7 +217,7 @@ const createDocument: BaseTool = { // Obter primeiro utilizador activo como createdById (necessário) const userResult = await pgClient.query( - `SELECT id FROM users WHERE "deletedAt" IS NULL AND "isSuspended" = false LIMIT 1` + `SELECT id FROM users WHERE "deletedAt" IS NULL AND "suspendedAt" IS NULL LIMIT 1` ); if (userResult.rows.length === 0) { diff --git a/src/tools/events.ts b/src/tools/events.ts index 5f79379..16e8a17 100644 --- a/src/tools/events.ts +++ b/src/tools/events.ts @@ -202,7 +202,7 @@ const getEvent: BaseTool<{ id: string }> = { e."createdAt", actor.name as "actorName", actor.email as "actorEmail", - actor."isAdmin" as "actorIsAdmin", + actor.role as "actorRole", u.name as "userName", u.email as "userEmail", c.name as "collectionName", diff --git a/src/tools/shares.ts b/src/tools/shares.ts index 6d03743..c8e72b3 100644 --- a/src/tools/shares.ts +++ b/src/tools/shares.ts @@ -260,7 +260,7 @@ const createShare: BaseTool = { // Get first admin user as creator const userQuery = await pgClient.query( - 'SELECT id FROM users WHERE "isAdmin" = true AND "deletedAt" IS NULL LIMIT 1' + `SELECT id FROM users WHERE role = 'admin' AND "deletedAt" IS NULL LIMIT 1` ); if (userQuery.rows.length === 0) { @@ -416,7 +416,7 @@ const revokeShare: BaseTool = { // Get first admin user as revoker const userQuery = await pgClient.query( - 'SELECT id FROM users WHERE "isAdmin" = true AND "deletedAt" IS NULL LIMIT 1' + `SELECT id FROM users WHERE role = 'admin' AND "deletedAt" IS NULL LIMIT 1` ); if (userQuery.rows.length === 0) {