{"record":{"id":"174b5d5c68bc6e7c","repo":"affaan-m/ECC","slug":"unauthorized-this-area-requires-role-role","errorCode":null,"errorMessage":"Unauthorized. This area requires role: {role}","messagePattern":"Unauthorized\\. This area requires role: (.+?)","errorType":"http","errorClass":null,"httpStatus":403,"severity":"error","filePath":"skills/laravel-security/SKILL.md","lineNumber":316,"sourceCode":"\n### Middleware Authorization\n\n```php\n// Using middleware in routes\nRoute::put('/posts/{post}', [PostController::class, 'update'])\n    ->middleware('can:update,post');\n\nRoute::get('/posts/create', [PostController::class, 'create'])\n    ->middleware('can:create,App\\Models\\Post');\n\n// Custom authorization middleware\n// app/Http/Middleware/CheckRole.php\nclass CheckRole\n{\n    public function handle(Request $request, Closure $next, string $role): mixed\n    {\n        if (!$request->user() || $request->user()->role !== $role) {\n            abort(403, 'Unauthorized. This area requires role: ' . $role);\n        }\n        return $next($request);\n    }\n}\n\n// Register in Kernel\nprotected $routeMiddleware = [\n    'role' => \\App\\Http\\Middleware\\CheckRole::class,\n];\n\n// Route usage\nRoute::middleware(['auth', 'role:admin'])->group(function () {\n    Route::get('/admin', [AdminController::class, 'index']);\n});\n```\n\n## Eloquent Security\n","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/affaan-m/ECC/blob/06c5e118c4d3e6c3b7f9445f973a2194c82de193/skills/laravel-security/SKILL.md#L298-L334","documentation":"Documented example in the laravel-security skill: a custom CheckRole middleware calls abort(403, ...) when the authenticated user's role does not match the middleware parameter, producing this 403 message.","triggerScenarios":"Triggered when SKILL.md rejects the current invocation: Unauthorized. This area requires role: <value>","commonSituations":"Occurs while running skills/laravel-security/SKILL.md with invalid arguments, missing flags, or a failing external dependency; the guard at skills/laravel-security/SKILL.md:316 aborts the command with this message.","solutions":["Provide valid credentials/configuration or wait for the rate-limit reset; verify permissions/role."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"06c5e118c4d3e6c3b7f9445f973a2194c82de193","analyzedAt":"2026-08-18T11:27:13.915Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}