Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
fix(Auth): Fix class check for route in AuthMiddleware failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Sep 18, 2019
1 parent a1bce3a commit 007d262
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
### Revert
- **Framework:** rename back to `framework` instead of ucfirst() (c325fb0)
- **Redis:** Remove view in redis , use other software install (c5d3378)
- **app:** Backup folder name to `application` (19121a6)

### Style
- **Bencode:** Move Bencode library to App\Library but not part of framework (01abc98)
Expand Down
3 changes: 2 additions & 1 deletion application/Middleware/AuthMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ public function handle($callable, \Closure $next)
* /admin/service -> AdminController::actionService -> route.admin_service
*/
$route = strtolower(str_replace(
['src\\controllers\\', 'Controller', 'action'], '',
['App\\Controllers\\', 'Controller', 'action'], '',
$controllerName . '_' . $action
)
);

$required_class = config('route.' . $route) ?: 1;
if ($curuser->getClass() < $required_class) {
return app()->response->setStatusCode(403); // FIXME redirect to /error may better
Expand Down
2 changes: 1 addition & 1 deletion config/http_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'GET maintenance' => ['maintenance', 'index'],

// API version 1
'Api/v1/{controller}/{action}' => ['Api/v1/{controller}', '{action}', 'middleware' => [
'api/v1/{controller}/{action}' => ['Api/v1/{controller}', '{action}', 'middleware' => [
App\Middleware\ApiMiddleware::class,
App\Middleware\AuthMiddleware::class
]],
Expand Down

0 comments on commit 007d262

Please sign in to comment.