import React, { useEffect } from 'react'; import { createPortal } from 'react-dom'; import { useNavigate } from 'react-router-dom'; import { ShieldAlert, LogOut, Ban, Mail, Building2, Fingerprint, Lock, } from 'lucide-react'; import { BrandLogo } from '../ui/BrandLogo'; import { AuthUserProfile, UserClaims } from '../../auth/AuthProvider'; import { cancelSessionExpiration, dismissSubordinateModals } from '../../services/sessionExpiration'; interface NonPartnerAccessDeniedModalProps { user: AuthUserProfile | null; claims: UserClaims; sub: string; roles: string[]; onLogout: () => Promise; } /** * Blocks any authenticated user who does NOT hold the 'Partner' role. * RBAC on PartnerUI strictly permits only Partner roles; no other roles are allowed. */ export const NonPartnerAccessDeniedModal: React.FC = ({ user, claims, sub, roles, onLogout, }) => { const navigate = useNavigate(); useEffect(() => { cancelSessionExpiration(); dismissSubordinateModals(); }, []); const displayName = user?.name || (claims.name as string) || (claims.preferred_username as string) || 'Authenticated User'; const displayEmail = user?.email || (claims.email as string) || (claims['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'] as string) || ''; const tenant = user?.tenant || (claims.tenant as string) || (claims.org as string) || 'Statutory Enterprise'; const assignedRolesDisplay = roles.length > 0 ? roles.join(', ') : user?.role || (claims.role as string) || 'Unassigned'; const handleLogoutClick = async () => { await onLogout(); navigate('/', { replace: true }); }; const modalContent = (
Partner Role Required Security Policy

Access Denied: Partner Accounts Only

This application is exclusively reserved for users assigned the Partner role. Your account role ({assignedRolesDisplay}) is not permitted on the Partner Portal.

Account Name {displayName}
{displayEmail && (
Email {displayEmail}
)}
Assigned Role(s) {assignedRolesDisplay}
{tenant && (
Organisation / Tenant {tenant}
)} {sub && (
Subject Key {sub}
)}

Portal Separation Notice

Internal staff, executives, programme managers, and administrators must sign in through the PFM Management Console. Only external grant recipients and project partners with the Partner role are permitted to use this portal.

PFM Partner Portal
Role Security Gate
); return typeof document !== 'undefined' ? createPortal(modalContent, document.body) : modalContent; };