diff --git a/backend/app/api/routes.py b/backend/app/api/routes.py index 2d159e3..61db577 100755 --- a/backend/app/api/routes.py +++ b/backend/app/api/routes.py @@ -611,9 +611,9 @@ async def get_analytics_by_agency( @router.get("/users", response_model=list[UserResponse]) async def list_users( db: AsyncSession = Depends(get_db), - current_user: User = Depends(require_role("super_admin")), + current_user: User = Depends(require_role("super_admin", "oversight_admin")), ): - """List all users (super_admin only).""" + """List all users (super_admin and oversight_admin).""" user_repo = UserRepository(db) users = await user_repo.list_all() @@ -706,9 +706,9 @@ async def update_user( async def get_user_change_history( user_id: uuid.UUID, db: AsyncSession = Depends(get_db), - current_user: User = Depends(require_role("super_admin")), + current_user: User = Depends(require_role("super_admin", "oversight_admin")), ): - """Get change history for a user (super_admin only).""" + """Get change history for a user (super_admin and oversight_admin).""" user_repo = UserRepository(db) logs = await user_repo.get_change_logs(user_id) return [ diff --git a/frontend/components/Sidebar.tsx b/frontend/components/Sidebar.tsx index c6dd862..e96b880 100755 --- a/frontend/components/Sidebar.tsx +++ b/frontend/components/Sidebar.tsx @@ -22,7 +22,7 @@ const navigation: NavItem[] = [ { name: 'Analytics', icon: AnalyticsIcon, roles: ['super_admin', 'oversight_admin', 'agency_admin'] }, { name: 'Auditing', icon: AuditIcon, roles: ['super_admin', 'oversight_admin'] }, { name: 'Knowledge Base', icon: KnowledgeBaseIcon, roles: ['super_admin'] }, - { name: 'User Management', icon: UserIcon, roles: ['super_admin'] }, + { name: 'User Management', icon: UserIcon, roles: ['super_admin', 'oversight_admin'] }, { name: 'Settings', icon: SettingsIcon, roles: ['super_admin', 'oversight_admin', 'agency_admin'] }, ]; diff --git a/frontend/components/UserManagement.tsx b/frontend/components/UserManagement.tsx index a0784a2..1ea9777 100644 --- a/frontend/components/UserManagement.tsx +++ b/frontend/components/UserManagement.tsx @@ -5,6 +5,7 @@ import { UserIcon } from './icons/UserIcon'; import { PlusIcon } from './icons/PlusIcon'; import { ChevronDownIcon } from './icons/ChevronDownIcon'; import { ClockIcon } from './icons/ClockIcon'; +import { useUser } from '../contexts/UserContext'; import type { UserRole } from '../types'; const ROLE_OPTIONS: { value: UserRole; label: string }[] = [ @@ -19,6 +20,7 @@ const formatDate = (iso: string) => { }; export const UserManagement: React.FC = () => { + const { isSuperAdmin } = useUser(); const [users, setUsers] = useState([]); const [agencies, setAgencies] = useState([]); const [isLoading, setIsLoading] = useState(true); @@ -205,7 +207,9 @@ export const UserManagement: React.FC = () => {

User Management

- Manage user roles and agency assignments. Users are provisioned automatically via Azure AD. + {isSuperAdmin + ? 'Manage user roles and agency assignments. Users are provisioned automatically via Azure AD.' + : 'View user roles and agency assignments.'}

@@ -256,33 +260,43 @@ export const UserManagement: React.FC = () => { {user.email} -
- - -
+ {isSuperAdmin ? ( +
+ + +
+ ) : ( + {formatRoleLabel(user.role)} + )} -
- - -
+ {isSuperAdmin ? ( +
+ + +
+ ) : ( + + {user.agency || 'Unassigned'} + + )} {formatDate(user.created_at)} @@ -453,23 +467,25 @@ export const UserManagement: React.FC = () => {

Agencies ({agencies.length})

-
- setNewAgencyName(e.target.value)} - placeholder="New agency name..." - className="flex-grow p-2 border-2 border-grey-700 rounded-[10px] focus:ring-2 focus:ring-active-blue focus:border-active-blue transition text-black-title" - /> - -
+ {isSuperAdmin && ( +
+ setNewAgencyName(e.target.value)} + placeholder="New agency name..." + className="flex-grow p-2 border-2 border-grey-700 rounded-[10px] focus:ring-2 focus:ring-active-blue focus:border-active-blue transition text-black-title" + /> + +
+ )}
{agencies.map(agency => ( diff --git a/frontend/contexts/UserContext.tsx b/frontend/contexts/UserContext.tsx index b132c04..454cd07 100644 --- a/frontend/contexts/UserContext.tsx +++ b/frontend/contexts/UserContext.tsx @@ -78,7 +78,7 @@ export const UserProvider: React.FC<{ children: React.ReactNode }> = ({ children canSeeAuditing: role === 'super_admin' || role === 'oversight_admin', canSeeKnowledgeBase: role === 'super_admin', canSeeSettings: role === 'super_admin' || role === 'oversight_admin' || role === 'agency_admin', - canSeeUserManagement: role === 'super_admin', + canSeeUserManagement: role === 'super_admin' || role === 'oversight_admin', canEditSettings: role === 'super_admin', isUnassigned: user != null && user.agencyId == null && role !== 'super_admin' && role !== 'oversight_admin',