Spaces:
Running

axeronis commited on
Commit
a69f086
·
1 Parent(s): 1f675da

fix(frontend): make admin role check case-insensitive in sidebar and dashboard

Browse files
frontend/app/dashboard/page.tsx CHANGED
@@ -99,7 +99,7 @@ export default function DashboardPage() {
99
  // Redirect managers to chats (they don't have access to analytics)
100
  useEffect(() => {
101
  if (!authLoading && user) {
102
- const isOwner = user.role?.toUpperCase() === 'OWNER' || user.role === 'admin' || user.is_superuser
103
  if (!isOwner) {
104
  router.replace('/chats')
105
  }
 
99
  // Redirect managers to chats (they don't have access to analytics)
100
  useEffect(() => {
101
  if (!authLoading && user) {
102
+ const isOwner = user.role?.toUpperCase() === 'OWNER' || user.role?.toUpperCase() === 'ADMIN' || user.is_superuser
103
  if (!isOwner) {
104
  router.replace('/chats')
105
  }
frontend/components/Sidebar.tsx CHANGED
@@ -124,8 +124,8 @@ export function Sidebar() {
124
  }
125
 
126
  const isActive = (path: string) => pathname === path || pathname.startsWith(path + '/')
127
- const isAdmin = user?.is_superuser || user?.role === 'admin'
128
- const isOwner = user?.role?.toUpperCase() === 'OWNER' || user?.role === 'admin' || user?.is_superuser
129
 
130
  // Filter items based on role
131
  const visibleMainItems = mainNavItems.filter(item => isOwner || !item.ownerOnly)
 
124
  }
125
 
126
  const isActive = (path: string) => pathname === path || pathname.startsWith(path + '/')
127
+ const isAdmin = user?.is_superuser || user?.role?.toUpperCase() === 'ADMIN'
128
+ const isOwner = user?.role?.toUpperCase() === 'OWNER' || user?.role?.toUpperCase() === 'ADMIN' || user?.is_superuser
129
 
130
  // Filter items based on role
131
  const visibleMainItems = mainNavItems.filter(item => isOwner || !item.ownerOnly)