diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index b3055da2..d4184abe 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -7,6 +7,7 @@ use App\Http\Requests\Admin\UserGenerate; use App\Http\Requests\Admin\UserSendMail; use App\Http\Requests\Admin\UserUpdate; use App\Jobs\SendEmailJob; +use App\Services\AuthService; use App\Services\UserService; use App\Utils\Helper; use Illuminate\Http\Request; @@ -128,6 +129,11 @@ class UserController extends Controller $params['invite_user_id'] = null; } + if (isset($params['banned']) && (int)$params['banned'] === 1) { + $authService = new AuthService($user); + $authService->removeAllSession(); + } + try { $user->update($params); } catch (\Exception $e) { diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index f506342e..c87b2af2 100755 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -39,7 +39,7 @@ class UserController extends Controller } $authService = new AuthService($user); return response([ - 'data' => $authService->delSession($request->input('session_id')) + 'data' => $authService->removeSession($request->input('session_id')) ]); } diff --git a/app/Services/AuthService.php b/app/Services/AuthService.php index 57f5f93b..078e9dd1 100644 --- a/app/Services/AuthService.php +++ b/app/Services/AuthService.php @@ -84,7 +84,7 @@ class AuthService return (array)Cache::get(CacheKey::get("USER_SESSIONS", $this->user->id), []); } - public function delSession($sessionId) + public function removeSession($sessionId) { $cacheKey = CacheKey::get("USER_SESSIONS", $this->user->id); $sessions = (array)Cache::get($cacheKey, []); @@ -95,4 +95,10 @@ class AuthService )) return false; return true; } + + public function removeAllSession() + { + $cacheKey = CacheKey::get("USER_SESSIONS", $this->user->id); + return Cache::forget($cacheKey); + } }