diff --git a/apps/sim/app/_shell/providers/session-provider.tsx b/apps/sim/app/_shell/providers/session-provider.tsx
index 50cef55ed83..7678f8b100b 100644
--- a/apps/sim/app/_shell/providers/session-provider.tsx
+++ b/apps/sim/app/_shell/providers/session-provider.tsx
@@ -13,6 +13,7 @@ export type AppSession = {
emailVerified?: boolean
name?: string | null
image?: string | null
+ role?: string
createdAt?: Date
updatedAt?: Date
} | null
diff --git a/apps/sim/app/api/user/super-user/route.ts b/apps/sim/app/api/user/super-user/route.ts
deleted file mode 100644
index 28c8b9733e1..00000000000
--- a/apps/sim/app/api/user/super-user/route.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { db } from '@sim/db'
-import { user } from '@sim/db/schema'
-import { createLogger } from '@sim/logger'
-import { eq } from 'drizzle-orm'
-import { type NextRequest, NextResponse } from 'next/server'
-import { getSession } from '@/lib/auth'
-import { generateRequestId } from '@/lib/core/utils/request'
-
-const logger = createLogger('SuperUserAPI')
-
-export const revalidate = 0
-
-// GET /api/user/super-user - Check if current user is a super user (database status)
-export async function GET(request: NextRequest) {
- const requestId = generateRequestId()
-
- try {
- const session = await getSession()
- if (!session?.user?.id) {
- logger.warn(`[${requestId}] Unauthorized super user status check attempt`)
- return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
- }
-
- const currentUser = await db
- .select({ isSuperUser: user.isSuperUser })
- .from(user)
- .where(eq(user.id, session.user.id))
- .limit(1)
-
- if (currentUser.length === 0) {
- logger.warn(`[${requestId}] User not found: ${session.user.id}`)
- return NextResponse.json({ error: 'User not found' }, { status: 404 })
- }
-
- return NextResponse.json({
- isSuperUser: currentUser[0].isSuperUser,
- })
- } catch (error) {
- logger.error(`[${requestId}] Error checking super user status`, error)
- return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
- }
-}
diff --git a/apps/sim/app/api/users/me/settings/route.ts b/apps/sim/app/api/users/me/settings/route.ts
index 78db186d483..b1277754c32 100644
--- a/apps/sim/app/api/users/me/settings/route.ts
+++ b/apps/sim/app/api/users/me/settings/route.ts
@@ -72,7 +72,7 @@ export async function GET() {
emailPreferences: userSettings.emailPreferences ?? {},
billingUsageNotificationsEnabled: userSettings.billingUsageNotificationsEnabled ?? true,
showTrainingControls: userSettings.showTrainingControls ?? false,
- superUserModeEnabled: userSettings.superUserModeEnabled ?? true,
+ superUserModeEnabled: userSettings.superUserModeEnabled ?? false,
errorNotificationsEnabled: userSettings.errorNotificationsEnabled ?? true,
snapToGridSize: userSettings.snapToGridSize ?? 0,
showActionBar: userSettings.showActionBar ?? true,
diff --git a/apps/sim/app/templates/[id]/template.tsx b/apps/sim/app/templates/[id]/template.tsx
index 249b11ecc90..c028f521387 100644
--- a/apps/sim/app/templates/[id]/template.tsx
+++ b/apps/sim/app/templates/[id]/template.tsx
@@ -148,7 +148,7 @@ export default function TemplateDetails({ isWorkspaceContext = false }: Template
const [currentUserOrgRoles, setCurrentUserOrgRoles] = useState<
Array<{ organizationId: string; role: string }>
>([])
- const [isSuperUser, setIsSuperUser] = useState(false)
+ const isSuperUser = session?.user?.role === 'admin'
const [isUsing, setIsUsing] = useState(false)
const [isEditing, setIsEditing] = useState(false)
const [isApproving, setIsApproving] = useState(false)
@@ -186,21 +186,6 @@ export default function TemplateDetails({ isWorkspaceContext = false }: Template
}
}
- const fetchSuperUserStatus = async () => {
- if (!currentUserId) return
-
- try {
- const response = await fetch('/api/user/super-user')
- if (response.ok) {
- const data = await response.json()
- setIsSuperUser(data.isSuperUser || false)
- }
- } catch (error) {
- logger.error('Error fetching super user status:', error)
- }
- }
-
- fetchSuperUserStatus()
fetchUserOrganizations()
}, [currentUserId])
diff --git a/apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx b/apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx
index 7342e267489..a9a007303c8 100644
--- a/apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx
+++ b/apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx
@@ -3,13 +3,14 @@
import dynamic from 'next/dynamic'
import { useSearchParams } from 'next/navigation'
import { Skeleton } from '@/components/emcn'
+import { useSession } from '@/lib/auth/auth-client'
+import { AdminSkeleton } from '@/app/workspace/[workspaceId]/settings/components/admin/admin-skeleton'
import { ApiKeysSkeleton } from '@/app/workspace/[workspaceId]/settings/components/api-keys/api-key-skeleton'
import { BYOKSkeleton } from '@/app/workspace/[workspaceId]/settings/components/byok/byok-skeleton'
import { CopilotSkeleton } from '@/app/workspace/[workspaceId]/settings/components/copilot/copilot-skeleton'
import { CredentialSetsSkeleton } from '@/app/workspace/[workspaceId]/settings/components/credential-sets/credential-sets-skeleton'
import { CredentialsSkeleton } from '@/app/workspace/[workspaceId]/settings/components/credentials/credential-skeleton'
import { CustomToolsSkeleton } from '@/app/workspace/[workspaceId]/settings/components/custom-tools/custom-tool-skeleton'
-import { DebugSkeleton } from '@/app/workspace/[workspaceId]/settings/components/debug/debug-skeleton'
import { GeneralSkeleton } from '@/app/workspace/[workspaceId]/settings/components/general/general-skeleton'
import { InboxSkeleton } from '@/app/workspace/[workspaceId]/settings/components/inbox/inbox-skeleton'
import { McpSkeleton } from '@/app/workspace/[workspaceId]/settings/components/mcp/mcp-skeleton'
@@ -130,10 +131,10 @@ const Inbox = dynamic(
import('@/app/workspace/[workspaceId]/settings/components/inbox/inbox').then((m) => m.Inbox),
{ loading: () =>
+ Import a workflow by ID along with its associated copilot chats. +
+{importWorkflow.error.message}
+ )} + {importWorkflow.isSuccess && ( ++ Workflow imported successfully (new ID: {importWorkflow.data.newWorkflowId},{' '} + {importWorkflow.data.copilotChatsImported ?? 0} copilot chats imported) +
+ )} +User Management
+ ++ {usersError instanceof Error ? usersError.message : 'Failed to fetch users'} +
+ )} + + {(setUserRole.error || banUser.error || unbanUser.error) && ( ++ {(setUserRole.error || banUser.error || unbanUser.error)?.message ?? + 'Action failed. Please try again.'} +
+ )} + + {usersLoading && !usersData && ( +- Import a workflow by ID along with its associated copilot chats. -
- -{importWorkflow.error.message}
- )} - - {importWorkflow.isSuccess && ( -- Workflow imported successfully (new ID: {importWorkflow.data.newWorkflowId},{' '} - {importWorkflow.data.copilotChatsImported ?? 0} copilot chats imported) -
- )} -