設定 / 認可
認可
Escalatedはエージェントビューと管理者ビューへのアクセスを制御するために2つの認可ゲートを使用します。アプリケーションでこれらを定義して、チケットを管理できるユーザーを制御してください。
注意: EscalatedはすべてのInertiaレスポンスに
page.props.escalatedを自動的に共有します。これにはルートプレフィックスと現在のユーザーのエージェント/管理者ステータスが含まれます。
Laravel 12+ ?? App\Providers\AppServiceProvider::boot() ??Laravel 11 ???? App\Providers\AuthServiceProvider::boot() ? 2 ???????????:
use Illuminate\Support\Facades\Gate;
// ??????????????????????????????????
Gate::define('escalated-agent', fn ($user) =>
$user->is_agent
);
// ???? (???SLA??????) ????????????
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
設定でcallableを定義します:
ESCALATED = {
"ADMIN_CHECK": lambda user: user.is_staff,
"AGENT_CHECK": lambda user: hasattr(user, "is_agent") and user.is_agent,
}
設定で認可コールバックを設定します:
authorization: {
isAgent: async (user) => {
return user.role === 'agent' || user.role === 'admin'
},
isAdmin: async (user) => {
return user.role === 'admin'
},
}
2つのLaravelゲートを定義し、Filamentプラグインでそれらを参照します:
Gate::define('escalated-agent', fn ($user) => $user->is_agent);
Gate::define('escalated-admin', fn ($user) => $user->is_admin);
EscalatedFilamentPlugin::make()
->agentGate('escalated-agent')
->adminGate('escalated-admin')
WordPressは組み込みのロールとケイパビリティを使用します。プラグインは2つのカスタムロールを登録します:
| ロール | 説明 |
|---|---|
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-agentandescalated-admingates 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-agentandescalated-admingates from your backend still apply to all API requests. The mobile app simply doesn't expose agent or admin views.