From c2328ec666096534b693cd095ae533e367539d9a Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sat, 9 May 2026 09:09:49 +0330 Subject: [PATCH 1/2] make auth service global --- .../Admin/Controllers/ProfileController.php | 19 +++++++++++++++ .../app/Admin/Resources/ExpertResource.php | 24 +++++++++++++++++++ .../Controllers}/AuthController.php | 14 ++++++----- .../Requests/Auth/LoginRequest.php | 5 ++-- .../Requests/Auth/RegisterRequest.php | 5 ++-- backend/app/User/Resources/UserResource.php | 0 backend/routes/api.php | 2 -- backend/routes/web.php | 2 +- 8 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 backend/app/Admin/Controllers/ProfileController.php create mode 100644 backend/app/Admin/Resources/ExpertResource.php rename backend/app/{User/Controller/Auth => Http/Controllers}/AuthController.php (82%) mode change 100755 => 100644 rename backend/app/{User => Http}/Requests/Auth/LoginRequest.php (77%) mode change 100755 => 100644 rename backend/app/{User => Http}/Requests/Auth/RegisterRequest.php (81%) mode change 100755 => 100644 mode change 100755 => 100644 backend/app/User/Resources/UserResource.php diff --git a/backend/app/Admin/Controllers/ProfileController.php b/backend/app/Admin/Controllers/ProfileController.php new file mode 100644 index 00000000..39d81669 --- /dev/null +++ b/backend/app/Admin/Controllers/ProfileController.php @@ -0,0 +1,19 @@ +successResponse(new ExpertResource(Auth::user())); + } +} diff --git a/backend/app/Admin/Resources/ExpertResource.php b/backend/app/Admin/Resources/ExpertResource.php new file mode 100644 index 00000000..b7c86e1c --- /dev/null +++ b/backend/app/Admin/Resources/ExpertResource.php @@ -0,0 +1,24 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'id' => $this->id, + 'username' => $this->username, + 'email' => $this->email, + ]; + } +} + diff --git a/backend/app/User/Controller/Auth/AuthController.php b/backend/app/Http/Controllers/AuthController.php old mode 100755 new mode 100644 similarity index 82% rename from backend/app/User/Controller/Auth/AuthController.php rename to backend/app/Http/Controllers/AuthController.php index cbd4f33d..26598504 --- a/backend/app/User/Controller/Auth/AuthController.php +++ b/backend/app/Http/Controllers/AuthController.php @@ -1,13 +1,11 @@ successResponse(new UserResource($user)); + return $this->successResponse([ + 'id' => $user->id, + 'username' => $user->username, + 'email' => $user->email, + ]); } return $this->errorResponse(__('messages.incorrect_or_username_password')); diff --git a/backend/app/User/Requests/Auth/LoginRequest.php b/backend/app/Http/Requests/Auth/LoginRequest.php old mode 100755 new mode 100644 similarity index 77% rename from backend/app/User/Requests/Auth/LoginRequest.php rename to backend/app/Http/Requests/Auth/LoginRequest.php index d9b9c881..592e8920 --- a/backend/app/User/Requests/Auth/LoginRequest.php +++ b/backend/app/Http/Requests/Auth/LoginRequest.php @@ -1,7 +1,8 @@ + * @return array */ public function rules(): array { diff --git a/backend/app/User/Requests/Auth/RegisterRequest.php b/backend/app/Http/Requests/Auth/RegisterRequest.php old mode 100755 new mode 100644 similarity index 81% rename from backend/app/User/Requests/Auth/RegisterRequest.php rename to backend/app/Http/Requests/Auth/RegisterRequest.php index 1c8055fe..9c7e9a84 --- a/backend/app/User/Requests/Auth/RegisterRequest.php +++ b/backend/app/Http/Requests/Auth/RegisterRequest.php @@ -1,7 +1,8 @@ + * @return array */ public function rules(): array { diff --git a/backend/app/User/Resources/UserResource.php b/backend/app/User/Resources/UserResource.php old mode 100755 new mode 100644 diff --git a/backend/routes/api.php b/backend/routes/api.php index 56897756..f35f6f84 100755 --- a/backend/routes/api.php +++ b/backend/routes/api.php @@ -1,10 +1,8 @@ user(); })->middleware('auth:api'); - diff --git a/backend/routes/web.php b/backend/routes/web.php index 8dc5599e..65362937 100755 --- a/backend/routes/web.php +++ b/backend/routes/web.php @@ -1,6 +1,6 @@ Date: Sun, 10 May 2026 14:25:12 +0330 Subject: [PATCH 2/2] prevent request forgery --- backend/Dockerfile | 1 - backend/bootstrap/app.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 3a24367a..6b930093 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -30,7 +30,6 @@ ENV COMPOSER_ALLOW_SUPERUSER=1 # Default command CMD composer install ;\ composer dump-autoload --optimize --classmap-authoritative ;\ - php artisan key:generate ;\ php artisan migrate ;\ php artisan db:seed ;\ php-fpm diff --git a/backend/bootstrap/app.php b/backend/bootstrap/app.php index 6de85c67..68a86469 100755 --- a/backend/bootstrap/app.php +++ b/backend/bootstrap/app.php @@ -12,7 +12,7 @@ return Application::configure(basePath: dirname(__DIR__)) health: '/up', ) ->withMiddleware(function (Middleware $middleware): void { - $middleware->web()->validateCsrfTokens(['*']); + $middleware->web()->preventRequestForgery(['*']); }) ->withExceptions(function (Exceptions $exceptions): void { // -- 2.49.1