![]() 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.quebec/private_html/src/components/ |
import React from 'react';
import { useSession } from 'next-auth/react';
import { useImpersonation } from '../hooks/useImpersonation';
import { X, User, Crown } from 'lucide-react';
import { signOut } from 'next-auth/react';
export default function ImpersonationBanner() {
const { data: session } = useSession();
const { stopImpersonation, isImpersonating } = useImpersonation();
// Only show banner if user is being impersonated
if (!session?.user?.isImpersonating || !session?.user?.originalUser) {
return null;
}
const handleStopImpersonation = async () => {
try {
await stopImpersonation();
} catch (e) {
alert('Failed to stop impersonation. Forcing sign out.');
signOut({ callbackUrl: '/auth/login' });
window.location.href = '/auth/login';
}
};
const handleForceSignOut = () => {
signOut({ callbackUrl: '/auth/login' });
window.location.href = '/auth/login';
};
return (
<div className="bg-red-600 text-white p-4 flex items-center justify-between z-50">
<div>
<b>Impersonation Mode:</b> You are impersonating another user.
</div>
<div className="flex gap-2">
<button
onClick={handleStopImpersonation}
className="bg-white text-red-700 px-4 py-2 rounded font-bold hover:bg-red-100 border border-red-700"
title="Stop Impersonation"
>
🚫 Stop Impersonation
</button>
<button
onClick={handleForceSignOut}
className="bg-white text-gray-700 px-4 py-2 rounded font-bold hover:bg-gray-100 border border-gray-400"
title="Force Sign Out (if stuck)"
>
Force Sign Out
</button>
</div>
</div>
);
}