mirror of
https://github.com/v2board/v2board.git
synced 2024-11-13 02:59:10 +08:00
update: session manage
This commit is contained in:
parent
2e251872b7
commit
044e8f6c30
@ -31,6 +31,18 @@ class UserController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function removeActiveSession(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->delSession($request->input('session_id'))
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function checkLogin(Request $request)
|
public function checkLogin(Request $request)
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
|
@ -22,11 +22,11 @@ class UserRoute
|
|||||||
$router->post('/transfer', 'User\\UserController@transfer');
|
$router->post('/transfer', 'User\\UserController@transfer');
|
||||||
$router->post('/getQuickLoginUrl', 'User\\UserController@getQuickLoginUrl');
|
$router->post('/getQuickLoginUrl', 'User\\UserController@getQuickLoginUrl');
|
||||||
$router->get ('/getActiveSession', 'User\\UserController@getActiveSession');
|
$router->get ('/getActiveSession', 'User\\UserController@getActiveSession');
|
||||||
|
$router->post('/removeActiveSession', 'User\\UserController@removeActiveSession');
|
||||||
// Order
|
// Order
|
||||||
$router->post('/order/save', 'User\\OrderController@save');
|
$router->post('/order/save', 'User\\OrderController@save');
|
||||||
$router->post('/order/checkout', 'User\\OrderController@checkout');
|
$router->post('/order/checkout', 'User\\OrderController@checkout');
|
||||||
$router->get ('/order/check', 'User\\OrderController@check');
|
$router->get ('/order/check', 'User\\OrderController@check');
|
||||||
$router->get ('/order/details', 'User\\OrderController@detail'); // TODO: 1.7.0 remove
|
|
||||||
$router->get ('/order/detail', 'User\\OrderController@detail');
|
$router->get ('/order/detail', 'User\\OrderController@detail');
|
||||||
$router->get ('/order/fetch', 'User\\OrderController@fetch');
|
$router->get ('/order/fetch', 'User\\OrderController@fetch');
|
||||||
$router->get ('/order/getPaymentMethod', 'User\\OrderController@getPaymentMethod');
|
$router->get ('/order/getPaymentMethod', 'User\\OrderController@getPaymentMethod');
|
||||||
|
@ -76,10 +76,23 @@ class AuthService
|
|||||||
$cacheKey,
|
$cacheKey,
|
||||||
$sessions
|
$sessions
|
||||||
)) return false;
|
)) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSessions()
|
public function getSessions()
|
||||||
{
|
{
|
||||||
return (array)Cache::get(CacheKey::get("USER_SESSIONS", $this->user->id), []);
|
return (array)Cache::get(CacheKey::get("USER_SESSIONS", $this->user->id), []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delSession($sessionId)
|
||||||
|
{
|
||||||
|
$cacheKey = CacheKey::get("USER_SESSIONS", $this->user->id);
|
||||||
|
$sessions = (array)Cache::get($cacheKey, []);
|
||||||
|
unset($sessions[$sessionId]);
|
||||||
|
if (!Cache::put(
|
||||||
|
$cacheKey,
|
||||||
|
$sessions
|
||||||
|
)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user