wokring models and image genration model and admin apges
This commit is contained in:
@@ -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 />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user