Files
SweetHome/app/hooks/useAuth.js
hamzaobed7 d65acbcc8f
All checks were successful
Build frontend / build (push) Successful in 1m33s
fixed route Notification
2026-08-26 20:50:25 +03:00

19 lines
511 B
JavaScript

// app/hooks/useAuth.js
import AuthService from "../services/AuthService";
export default function useAuth() {
const authUser = AuthService.getUser();
const role = authUser?.roles;
return {
user: authUser,
name: authUser?.name ?? "Not found",
email: authUser?.email ?? "Not found",
isOwner: role?.includes("Owner"),
isAgent: role?.includes("RealEstateAgent"),
isCustomer: role?.includes("Customer"),
role: role,
isGuest: !authUser,
isAuthenticated: !!authUser,
};
}