Escalated utilise deux gates d'autorisation pour controler l'acces aux vues agent et administration. Definissez-les dans votre application pour controler qui peut gerer les tickets.
Remarque : Escalated partage automatiquement page.props.escalated dans toutes les reponses Inertia, contenant le prefixe de route et le statut agent/admin de l'utilisateur actuel.
Definissez deux gates dans App\Providers\AppServiceProvider::boot() pour Laravel 12+, ou dans App\Providers\AuthServiceProvider::boot() pour Laravel 11 et les versions anterieures :
use Illuminate\Support\Facades\Gate;
// Qui peut acceder au tableau de bord agent et gerer les tickets
Gate::define('escalated-agent', fn ($user) =>
$user->is_agent
);
// Qui peut acceder aux parametres admin (departements, SLAs, regles, etc.)
Gate::define('escalated-admin', fn ($user) =>
$user->is_admin
);
Les noms des gates sont configurables via config/escalated.php sous authorization.admin_gate et authorization.agent_gate.
Configurez les lambdas dans l'initialisateur :
Escalated.configure do |config|
config.admin_check = ->(user) { user.admin? }
config.agent_check = ->(user) { user.agent? || user.admin? }
end
WordPress utilise les roles et capacites integres. Le plugin enregistre deux roles personnalises :
Role
Description
escalated_agent
Peut voir et gerer les tickets
escalated_admin
Acces complet aux parametres, departements et politiques 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.