diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index 7f81ecfb..5c25a925 100755 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\User\UserTransfer; use App\Http\Requests\User\UserUpdate; use App\Http\Requests\User\UserChangePassword; +use App\Services\AuthService; use App\Services\UserService; use App\Utils\CacheKey; use Illuminate\Http\Request; @@ -18,6 +19,18 @@ use Illuminate\Support\Facades\Cache; class UserController extends Controller { + public function getActiveSession(Request $request) + { + $user = User::find($request->user['id']); + if (!$user) { + abort(500, __('The user does not exist')); + } + $authService = new AuthService($user); + return response([ + 'data' => $authService->getSessions() + ]); + } + public function checkLogin(Request $request) { $data = [ diff --git a/app/Http/Routes/UserRoute.php b/app/Http/Routes/UserRoute.php index 01da8bbf..5d245160 100644 --- a/app/Http/Routes/UserRoute.php +++ b/app/Http/Routes/UserRoute.php @@ -21,6 +21,7 @@ class UserRoute $router->get ('/checkLogin', 'User\\UserController@checkLogin'); $router->post('/transfer', 'User\\UserController@transfer'); $router->post('/getQuickLoginUrl', 'User\\UserController@getQuickLoginUrl'); + $router->get ('/getActiveSession', 'User\\UserController@getActiveSession'); // Order $router->post('/order/save', 'User\\OrderController@save'); $router->post('/order/checkout', 'User\\OrderController@checkout'); diff --git a/app/Services/AuthService.php b/app/Services/AuthService.php index 16763f26..b04a480e 100644 --- a/app/Services/AuthService.php +++ b/app/Services/AuthService.php @@ -14,7 +14,7 @@ class AuthService { private $user; - public function __construct($user) + public function __construct(User $user) { $this->user = $user; }