![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.ca/private_html/src/pages/ |
import React from 'react';
import { useSession } from 'next-auth/react';
import LayoutWithSidebar from '../components/LayoutWithSidebar';
import { useRequireRole, USER_ROLES, canAccessPage } from '../lib/auth-utils';
import AccessControl from '../components/AccessControl';
const TestAccessPage: React.FC = () => {
const { data: session, status } = useSession();
return (
<LayoutWithSidebar>
<div className="max-w-4xl mx-auto px-4 py-8">
<h1 className="text-3xl font-bold text-gray-900 mb-8">Access Control Test Page</h1>
<div className="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-6">
<h2 className="text-xl font-semibold text-gray-900 mb-4">Session Information</h2>
<div className="space-y-2">
<p><strong>Status:</strong> {status}</p>
<p><strong>User ID:</strong> {session?.user?.id || 'Not authenticated'}</p>
<p><strong>Email:</strong> {session?.user?.email || 'Not authenticated'}</p>
<p><strong>Role:</strong> {session?.user?.role || 'Not authenticated'}</p>
<p><strong>Name:</strong> {session?.user?.name || 'Not authenticated'}</p>
</div>
</div>
<div className="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-6">
<h2 className="text-xl font-semibold text-gray-900 mb-4">Access Control Tests</h2>
<div className="space-y-4">
<div className="p-4 bg-blue-50 rounded-lg">
<h3 className="font-semibold text-blue-900 mb-2">User Dashboard Access</h3>
<p className="text-blue-700">
Can access /user/dashboard: {
session?.user?.role && canAccessPage(session.user.role as any, '/user/dashboard')
? '✅ Yes'
: '❌ No'
}
</p>
</div>
<div className="p-4 bg-green-50 rounded-lg">
<h3 className="font-semibold text-green-900 mb-2">Lawyer Dashboard Access</h3>
<p className="text-green-700">
Can access /lawyer/dashboard: {
session?.user?.role && canAccessPage(session.user.role as any, '/lawyer/dashboard')
? '✅ Yes'
: '❌ No'
}
</p>
</div>
<div className="p-4 bg-purple-50 rounded-lg">
<h3 className="font-semibold text-purple-900 mb-2">Admin Dashboard Access</h3>
<p className="text-purple-700">
Can access /admin/dashboard: {
session?.user?.role && canAccessPage(session.user.role as any, '/admin/dashboard')
? '✅ Yes'
: '❌ No'
}
</p>
</div>
<div className="p-4 bg-orange-50 rounded-lg">
<h3 className="font-semibold text-orange-900 mb-2">Jurist Dashboard Access</h3>
<p className="text-orange-700">
Can access /jurist/dashboard: {
session?.user?.role && canAccessPage(session.user.role as any, '/jurist/dashboard')
? '✅ Yes'
: '❌ No'
}
</p>
</div>
</div>
</div>
<div className="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h2 className="text-xl font-semibold text-gray-900 mb-4">Role-Based Access Control Test</h2>
<AccessControl
allowedRoles={[USER_ROLES.LAWYER, USER_ROLES.ADMIN, USER_ROLES.SUPERADMIN, USER_ROLES.SUPERADMIN]}
currentPage="/test-access"
redirectTo="/"
>
<div className="p-4 bg-green-100 rounded-lg border border-green-300">
<h3 className="font-semibold text-green-900 mb-2">✅ Access Granted</h3>
<p className="text-green-700">
You have access to this restricted section because you have one of the required roles:
LAWYER, ADMIN, or SUPERADMIN
</p>
</div>
</AccessControl>
</div>
</div>
</LayoutWithSidebar>
);
};
export default TestAccessPage;