update: add get active session api

This commit is contained in:
v2board 2022-12-18 15:03:23 +08:00
parent f621619cc4
commit 2e251872b7
3 changed files with 15 additions and 1 deletions

View File

@ -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 = [

View File

@ -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');

View File

@ -14,7 +14,7 @@ class AuthService
{
private $user;
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}