feature/ForgotPassword #29
@@ -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
|
||||
|
||||
19
backend/app/Admin/Controllers/ProfileController.php
Normal file
19
backend/app/Admin/Controllers/ProfileController.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Resources\ExpertResource;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Traits\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function info(): JsonResponse
|
||||
{
|
||||
return $this->successResponse(new ExpertResource(Auth::user()));
|
||||
}
|
||||
}
|
||||
24
backend/app/Admin/Resources/ExpertResource.php
Normal file
24
backend/app/Admin/Resources/ExpertResource.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ExpertResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'username' => $this->username,
|
||||
'email' => $this->email,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
14
backend/app/User/Controller/Auth/AuthController.php → backend/app/Http/Controllers/AuthController.php
Executable file → Normal file
14
backend/app/User/Controller/Auth/AuthController.php → backend/app/Http/Controllers/AuthController.php
Executable file → Normal file
@@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Controller\Auth;
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Auth\LoginRequest;
|
||||
use App\Http\Requests\Auth\RegisterRequest;
|
||||
use App\Models\User;
|
||||
use App\Traits\ApiResponse;
|
||||
use App\User\Requests\Auth\LoginRequest;
|
||||
use App\User\Requests\Auth\RegisterRequest;
|
||||
use App\User\Resources\UserResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -46,7 +44,11 @@ class AuthController extends Controller
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
return $this->successResponse(new UserResource($user));
|
||||
return $this->successResponse([
|
||||
'id' => $user->id,
|
||||
'username' => $user->username,
|
||||
'email' => $user->email,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->errorResponse(__('messages.incorrect_or_username_password'));
|
||||
5
backend/app/User/Requests/Auth/LoginRequest.php → backend/app/Http/Requests/Auth/LoginRequest.php
Executable file → Normal file
5
backend/app/User/Requests/Auth/LoginRequest.php → backend/app/Http/Requests/Auth/LoginRequest.php
Executable file → Normal file
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Requests\Auth;
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
@@ -17,7 +18,7 @@ class LoginRequest extends FormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
5
backend/app/User/Requests/Auth/RegisterRequest.php → backend/app/Http/Requests/Auth/RegisterRequest.php
Executable file → Normal file
5
backend/app/User/Requests/Auth/RegisterRequest.php → backend/app/Http/Requests/Auth/RegisterRequest.php
Executable file → Normal file
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Requests\Auth;
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RegisterRequest extends FormRequest
|
||||
@@ -17,7 +18,7 @@ class RegisterRequest extends FormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
0
backend/app/User/Resources/UserResource.php
Executable file → Normal file
0
backend/app/User/Resources/UserResource.php
Executable file → Normal file
@@ -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 {
|
||||
//
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\User\Controller\Auth\AuthController;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
})->middleware('auth:api');
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\User\Controller\Auth\AuthController;
|
||||
use App\Http\Controllers\AuthController;
|
||||
use App\User\Controller\ProfileController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user