Escalated używa dwóch bramek autoryzacyjnych do kontroli dostępu do widoków agentów i administratorów. Zdefiniuj je w swojej aplikacji, aby kontrolować, kto może zarządzać zgłoszeniami.
Uwaga: Escalated automatycznie udostępnia page.props.escalated we wszystkich odpowiedziach Inertia, zawierając prefiks tras oraz status agenta/administratora bieżącego użytkownika.
Zdefiniuj dwie bramki w App\Providers\AppServiceProvider::boot() dla Laravel 12+ albo w App\Providers\AuthServiceProvider::boot() dla Laravel 11 i starszych:
use Illuminate\Support\Facades\Gate;
// Kto moze uzyskac dostep do panelu agenta i zarzadzac zgloszeniami
Gate::define('escalated-agent', fn ($user) =>
$user->is_agent
);
// Kto moze uzyskac dostep do ustawien administracyjnych (dzialy, SLA, reguly itd.)
Gate::define('escalated-admin', fn ($user) =>
$user->is_admin
);
Nazwy bramek są konfigurowalne w pliku config/escalated.php pod kluczami authorization.admin_gate i authorization.agent_gate.
Skonfiguruj lambdy w inicjalizatorze:
Escalated.configure do |config|
config.admin_check = ->(user) { user.admin? }
config.agent_check = ->(user) { user.agent? || user.admin? }
end
Zdefiniuj wywoływalne obiekty w swoich ustawieniach:
WordPress wykorzystuje wbudowane role i uprawnienia. Wtyczka rejestruje dwie niestandardowe role:
Rola
Opis
escalated_agent
Może wyświetlać i zarządzać zgłoszeniami
escalated_admin
Pełny dostęp do ustawień, działów i polityk 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.