This commit is contained in:
glovetleong
2021-09-07 15:45:19 +08:00
parent 1f6ac53a23
commit 1dfe8d613c
5 changed files with 19 additions and 9 deletions
@@ -48,7 +48,7 @@ class FetchUserLogic extends AbstractControllerLogic
public function logic(Request $request) : JsonResponse
{
try {
$this->canFetchUser->passes();
$query = $this->fetchessUser->execute(['id' => $request->input('user_id')]);
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Accounts;
use App\Classes\Modules\Accounts\ControllersLogic\AuthenticateUserLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
class UserAuthenticationController
{
@@ -15,6 +16,11 @@ class UserAuthenticationController
* @return JsonResponse
*/
public function authenticate(Request $request, AuthenticateUserLogic $logic): JsonResponse {
$response = Http::withToken('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9zaGlwcGluZy1wb3J0YWwudGVzdFwvYXBpXC92MVwvYWNjb3VudFwvYXV0aGVudGljYXRpb25cL2xvZ2luXC9hdHRlbXB0IiwiaWF0IjoxNjMwNTY4NzU5LCJleHAiOjk5NDY5ODc4Mjk5LCJuYmYiOjE2MzA1Njg3NTksImp0aSI6ImQ0NGZTbnNtdlQ1Z0FrN20iLCJ1c2VyIjp7ImlkIjoyLCJuYW1lIjoiQWRtaW4iLCJlbWFpbCI6ImFkbWluQGNpZWYtbWFsYXlzaWEuY29tIiwidHlwZSI6Miwic3RhdHVzIjoyfSwic3ViIjoyLCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.1FM75NcuRA7g-s4uqXP43TY6AeY1e6mkEl3QAk6R0WQ')->get('http://shipping-portal.test/api/v1/account/user/list')->object();
dd($response);
return $logic->execute($request);
}
+2
View File
@@ -33,6 +33,8 @@ class ValidateToken
*/
public function handle($request, Closure $next)
{
return response()->json(['status' =>2, 'msg' => $this->manager->getPayload()]);
try {
if(!$this->manager->check()){ throw new AccessUnauthorisedException(); }
+1 -1
View File
@@ -12,6 +12,6 @@ class VerifyCsrfToken extends Middleware
* @var array
*/
protected $except = [
//
'api/v1/*',
];
}
+9 -7
View File
@@ -33,13 +33,15 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account
Route::post('/verification/resend', 'ResendEmailVerificationController@resend')->name('verification.resend');
});
Route::group(['middleware' => 'valid.token'], function () {
Route::group(['prefix' => 'user', 'as' => 'user.'], function () {
Route::post('/show', 'FetchUserController@fetch')->name('show');
Route::get('/list', 'ListUsersController@list')->name('list');
Route::put('/update/{id}', 'UpdateUserController@update')->name('update');
Route::post('/admin/create', 'CreateAdminUserController@create')->name('admin.create');
Route::delete('/delete/{id}', 'DeleteUserController@delete')->name('delete');
Route::group(['prefix' => 'user', 'as' => 'user.'], function () {
Route::post('/show', 'FetchUserController@fetch')->name('show');
Route::get('/list', 'ListUsersController@list')->name('list');
Route::put('/update/{id}', 'UpdateUserController@update')->name('update');
Route::post('/admin/create', 'CreateAdminUserController@create')->name('admin.create');
Route::delete('/delete/{id}', 'DeleteUserController@delete')->name('delete');
});
});
});