T.ME/BIBIL_0DAY
CasperSecurity


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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/lavocat.ca/private_html/src/pages/dashboard-fixed.tsx
import { useSession } from 'next-auth/react';
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import LayoutWithSidebar from '../components/LayoutWithSidebar';
import { Loader2, AlertTriangle } from 'lucide-react';

export default function DashboardFixed() {
  const { data: session, status } = useSession();
  const router = useRouter();
  const [redirectAttempted, setRedirectAttempted] = useState(false);

  useEffect(() => {
    // Only attempt redirect once
    if (redirectAttempted) return;
    
    if (status === 'loading') return;

    if (!session) {
      router.push('/auth/login');
      return;
    }

    setRedirectAttempted(true);
    
    // Simple redirect based on role
    const role = session.user.role;
    let targetRoute = '/user/dashboard'; // default
    
    if (role === 'ADMIN' || role === 'SUPERADMIN' || role === 'SUPERADMIN') {
      targetRoute = '/admin/dashboard';
    } else if (role === 'LAWYER') {
      targetRoute = '/lawyer/dashboard';
    } else if (role === 'JURIST') {
      targetRoute = '/jurist/dashboard';
    } else if (role === 'JUDGE') {
      targetRoute = '/judge/dashboard';
    } else if (role === 'MEDIATOR') {
      targetRoute = '/mediator/dashboard';
    } else if (role === 'LEGAL_CONSULTANT') {
      targetRoute = '/consultant/dashboard';
    } else if (role === 'INVESTIGATOR') {
      targetRoute = '/investigator/dashboard';
    } else if (role === 'EXPERT_WITNESS') {
      targetRoute = '/expert/dashboard';
    } else if (['SUPPORT_STAFF', 'SECRETARY', 'ASSISTANT', 'CLERK', 'COURT_CLERK', 'PARALEGAL'].includes(role)) {
      targetRoute = '/support/dashboard';
    } else if (role === 'STUDENT') {
      targetRoute = '/student/dashboard';
    } else if (role === 'NOTARY') {
      targetRoute = '/notary/dashboard';
    }
    
    // Use replace instead of push to avoid back button issues
    router.replace(targetRoute);
  }, [session, status, router, redirectAttempted]);

  if (status === 'loading') {
    return (
      <LayoutWithSidebar>
        <div className="min-h-screen flex items-center justify-center">
          <div className="text-center">
            <Loader2 className="h-8 w-8 animate-spin mx-auto mb-4 text-blue-600" />
            <h2 className="text-xl font-semibold text-gray-900 mb-2">Loading Dashboard</h2>
            <p className="text-gray-600">Please wait while we load your dashboard...</p>
          </div>
        </div>
      </LayoutWithSidebar>
    );
  }

  if (!session) {
    return (
      <LayoutWithSidebar>
        <div className="min-h-screen flex items-center justify-center">
          <div className="text-center">
            <AlertTriangle className="h-8 w-8 mx-auto mb-4 text-red-600" />
            <h2 className="text-xl font-semibold text-gray-900 mb-2">Authentication Required</h2>
            <p className="text-gray-600 mb-4">Please sign in to access your dashboard.</p>
            <button
              onClick={() => router.push('/auth/login')}
              className="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition-colors"
            >
              Sign In
            </button>
          </div>
        </div>
      </LayoutWithSidebar>
    );
  }

  // Show a loading state while redirecting
  return (
    <LayoutWithSidebar>
      <div className="min-h-screen flex items-center justify-center">
        <div className="text-center">
          <Loader2 className="h-8 w-8 animate-spin mx-auto mb-4 text-blue-600" />
          <h2 className="text-xl font-semibold text-gray-900 mb-2">
            Welcome, {session.user.name}!
          </h2>
          <p className="text-gray-600 mb-4">
            Redirecting to your {session.user.role.toLowerCase().replace('_', ' ')} dashboard...
          </p>
          <div className="text-sm text-gray-500">
            If you're not redirected automatically, click below:
          </div>
          <div className="mt-4 space-x-2">
            <button
              onClick={() => router.push('/user/dashboard')}
              className="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700 transition-colors"
            >
              User Dashboard
            </button>
            <button
              onClick={() => router.push('/admin/dashboard')}
              className="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700 transition-colors"
            >
              Admin Dashboard
            </button>
          </div>
        </div>
      </div>
    </LayoutWithSidebar>
  );
} 

CasperSecurity Mini