completionId: cgen-7915b7bcda044042b76cba6e43b9fe3b
cgen-7915b7bcda044042b76cba6e43b9fe3b
This commit is contained in:
parent
8399b8d17e
commit
d2f63ce70b
1 changed files with 8 additions and 6 deletions
|
|
@ -57,13 +57,15 @@ import {
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
|
|
||||||
export default function Admin() {
|
export default function Admin() {
|
||||||
const { user, loading, roles } = useAuth();
|
const { user, loading } = useAuth();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const ownerEmail = "mrpiglr@gmail.com";
|
|
||||||
const normalizedEmail = user?.email?.toLowerCase() ?? "";
|
// Redirect to login if not authenticated
|
||||||
const isOwner =
|
useEffect(() => {
|
||||||
(Array.isArray(roles) && roles.includes("owner")) ||
|
if (!loading && !user) {
|
||||||
normalizedEmail === ownerEmail;
|
navigate("/login", { replace: true });
|
||||||
|
}
|
||||||
|
}, [user, loading, navigate]);
|
||||||
const [managedProfiles, setManagedProfiles] = useState<AethexUserProfile[]>(
|
const [managedProfiles, setManagedProfiles] = useState<AethexUserProfile[]>(
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue