Escalated utilizza due gate di autorizzazione per controllare l'accesso alle viste agente e admin. Definiscili nella tua applicazione per controllare chi può gestire i ticket.
Nota: Escalated condivide automaticamente page.props.escalated in tutte le risposte Inertia, contenendo il prefisso delle route e lo stato agente/admin dell'utente corrente.
Definisci due gate in App\Providers\AppServiceProvider::boot() per Laravel 12+, oppure in App\Providers\AuthServiceProvider::boot() per Laravel 11 e versioni precedenti:
use Illuminate\Support\Facades\Gate;
// Chi può accedere alla dashboard agente e gestire i ticket
Gate::define('escalated-agent', fn ($user) =>
$user->is_agent
);
// Chi può accedere alle impostazioni admin (dipartimenti, SLA, regole, ecc.)
Gate::define('escalated-admin', fn ($user) =>
$user->is_admin
);
I nomi dei gate sono configurabili tramite config/escalated.php sotto authorization.admin_gate e authorization.agent_gate.
Configura le lambda nell'inizializzatore:
Escalated.configure do |config|
config.admin_check = ->(user) { user.admin? }
config.agent_check = ->(user) { user.agent? || user.admin? }
end
WordPress utilizza ruoli e capability integrati. Il plugin registra due ruoli personalizzati:
Ruolo
Descrizione
escalated_agent
Può visualizzare e gestire i ticket
escalated_admin
Accesso completo a impostazioni, dipartimenti e policy 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.