Skip to content

Commit

Permalink
feat: move flag admin
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Dec 6, 2024
1 parent cbb5e60 commit 3266cb2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion app/Controllers/Api/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public function login(AuthRequest $request, JsonResponse $json): JsonResponse
'iat' => $time,
'exp' => $time + (60 * 60),
'iss' => base_url(),
'is_admin' => true,
...Auth::user()->only(['id', 'name', 'email'])->toArray()
],
env('JWT_KEY'),
Expand Down
2 changes: 2 additions & 0 deletions app/Middleware/AuthMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function handle(Request $request, Closure $next)
new Key(env('JWT_KEY'), env('JWT_ALGO', 'HS256'))
));

$user->is_admin = true;

Auth::login($user);
} catch (Exception $e) {
return (new JsonResponse)->errorBadRequest([$e->getMessage()]);
Expand Down

0 comments on commit 3266cb2

Please sign in to comment.