From 311f9fcefb22a8d9cd6c0017c4d94b3a3924c1e5 Mon Sep 17 00:00:00 2001 From: Juan Font Date: Tue, 3 Jul 2018 05:35:10 +0200 Subject: [PATCH] Implemented method to get info on the current user of the API (#5722) * Implemented method to get info on the current user of the API * Move userinfo method to UsersController * Added missing files --- app/Http/Controllers/Api/UsersController.php | 13 +++++++++++++ routes/api.php | 11 +++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 73aeb2a993..c683dbf917 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -320,4 +320,17 @@ class UsersController extends Controller return response()->json(['message' => 'No ID provided'], 500); } + + /** + * Get info on the current user. + * + * @author [Juan Font] [] + * @since [v4.4.2] + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function getCurrentUserInfo(Request $request) + { + return response()->json($request->user()); + } } diff --git a/routes/api.php b/routes/api.php index 97c032caa6..c66c388820 100644 --- a/routes/api.php +++ b/routes/api.php @@ -674,10 +674,10 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { + /*--- Users API ---*/ - - + Route::group([ 'prefix' => 'users' ], function () { Route::post('two_factor_reset', @@ -687,6 +687,13 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { ] ); + Route::get('me', + [ + 'as' => 'api.users.me', + 'uses' => 'UsersController@getCurrentUserInfo' + ] + ); + Route::get('list/{status?}', [ 'as' => 'api.users.list',