Escalated utiliza dos gates de autorizacion para controlar el acceso a las vistas de agentes y administradores. Definalos en tu aplicacion para controlar quien puede gestionar tickets.
Nota: Escalated comparte automaticamente page.props.escalated en todas las respuestas de Inertia, conteniendo el prefijo de ruta y el estado de agente/administrador del usuario actual.
Define dos gates en App\Providers\AppServiceProvider::boot() para Laravel 12+, o en App\Providers\AuthServiceProvider::boot() para Laravel 11 y anteriores:
use Illuminate\Support\Facades\Gate;
// Quien puede acceder al panel de agentes y gestionar tickets
Gate::define('escalated-agent', fn ($user) =>
$user->is_agent
);
// Quien puede acceder a la configuracion de administracion (departamentos, SLAs, reglas, etc.)
Gate::define('escalated-admin', fn ($user) =>
$user->is_admin
);
Los nombres de los gates son configurables a traves de config/escalated.php bajo authorization.admin_gate y authorization.agent_gate.
Configura lambdas en el inicializador:
Escalated.configure do |config|
config.admin_check = ->(user) { user.admin? }
config.agent_check = ->(user) { user.agent? || user.admin? }
end
WordPress utiliza roles y capacidades integrados. El plugin registra dos roles personalizados:
Rol
Descripcion
escalated_agent
Puede ver y gestionar tickets
escalated_admin
Acceso completo a configuracion, departamentos y politicas SLA
Authorization is handled entirely server-side. The Flutter package sends a Bearer token with each request, and your backend API controls what the authenticated user can access.
There are no client-side gates to define — the mobile app is a customer-facing UI, so agent and admin authorization checks only apply on the web.
Checking Auth State
Use the authProvider to check whether the current user is authenticated:
final authState = ref.watch(authProvider);
if (authState.isAuthenticated) {
// User is logged in, show ticket list
} else {
// Show login screen
}
Note: The escalated-agent and escalated-admin gates from your backend still apply to all API requests. The mobile app simply doesn't expose agent or admin views.
Authorization is handled entirely server-side. The React Native package sends a Bearer token with each request, and your backend API controls what the authenticated user can access.
There are no client-side gates to define — the mobile app is a customer-facing UI, so agent and admin authorization checks only apply on the web.
Checking Auth State
Use the useAuth hook to access the current user and authentication status:
import { useAuth } from '@escalated-dev/escalated-react-native';
function ProfileScreen() {
const { user, isAuthenticated } = useAuth();
if (!isAuthenticated) {
return <LoginScreen />;
}
return <Text>Welcome, {user.name}</Text>;
}
Note: The escalated-agent and escalated-admin gates from your backend still apply to all API requests. The mobile app simply doesn't expose agent or admin views.