يستخدم Escalated بوابتي تفويض للتحكم في الوصول إلى واجهات الوكلاء والمسؤولين. حددها في تطبيقك للتحكم في من يمكنه إدارة التذاكر.
ملاحظة: يشارك Escalated تلقائيًا page.props.escalated لجميع استجابات Inertia، ويحتوي على بادئة المسار وحالة الوكيل/المسؤول للمستخدم الحالي.
عرّف بوابتين في App\Providers\AppServiceProvider::boot() في Laravel 12+، أو في App\Providers\AuthServiceProvider::boot() في Laravel 11 والإصدارات الأقدم:
use Illuminate\Support\Facades\Gate;
// من يمكنه الوصول إلى لوحة تحكم الوكيل وإدارة التذاكر
Gate::define('escalated-agent', fn ($user) =>
$user->is_agent
);
// من يمكنه الوصول إلى إعدادات الإدارة (الأقسام، SLAs، القواعد، إلخ)
Gate::define('escalated-admin', fn ($user) =>
$user->is_admin
);
أسماء البوابات قابلة للتكوين عبر config/escalated.php تحت authorization.admin_gate و authorization.agent_gate.
كوّن دوال لامدا في المُهيِّئ:
Escalated.configure do |config|
config.admin_check = ->(user) { user.admin? }
config.agent_check = ->(user) { user.agent? || user.admin? }
end
يستخدم WordPress الأدوار والصلاحيات المدمجة. تسجل الإضافة دورين مخصصين:
الدور
الوصف
escalated_agent
يمكنه عرض وإدارة التذاكر
escalated_admin
وصول كامل إلى الإعدادات والأقسام وسياسات 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.