wokring models and image genration model and admin apges

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-03 17:28:18 +00:00
parent 52600c9dca
commit a1016ec1c2
15 changed files with 1119 additions and 25 deletions

View File

@@ -8,7 +8,8 @@ interface AdminRouteProps {
/**
* AdminRoute component - guards routes requiring admin or staff privileges
* Redirects to dashboard if user is not admin/staff
* OR users belonging to the aws-admin account
* Redirects to dashboard if user doesn't meet requirements
*/
export default function AdminRoute({ children }: AdminRouteProps) {
const { user, isAuthenticated } = useAuthStore();
@@ -19,12 +20,14 @@ export default function AdminRoute({ children }: AdminRouteProps) {
return null;
}
// Check if user is admin or staff
// Check if user is admin/staff OR belongs to aws-admin account
const isAdmin = user?.role === 'admin' || user?.is_staff === true;
const isAwsAdminAccount = user?.account?.name === 'aws-admin' || user?.account?.slug === 'aws-admin';
const hasAccess = isAdmin || isAwsAdminAccount;
if (!isAdmin) {
// Redirect non-admin users to dashboard
console.log('AdminRoute: User is not admin/staff, redirecting to dashboard');
if (!hasAccess) {
// Redirect unauthorized users to dashboard
console.log('AdminRoute: User does not have admin access, redirecting to dashboard');
return <Navigate to="/" state={{ from: location }} replace />;
}