mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	update: banned user remove session
This commit is contained in:
		| @@ -7,6 +7,7 @@ use App\Http\Requests\Admin\UserGenerate; | |||||||
| use App\Http\Requests\Admin\UserSendMail; | use App\Http\Requests\Admin\UserSendMail; | ||||||
| use App\Http\Requests\Admin\UserUpdate; | use App\Http\Requests\Admin\UserUpdate; | ||||||
| use App\Jobs\SendEmailJob; | use App\Jobs\SendEmailJob; | ||||||
|  | use App\Services\AuthService; | ||||||
| use App\Services\UserService; | use App\Services\UserService; | ||||||
| use App\Utils\Helper; | use App\Utils\Helper; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
| @@ -128,6 +129,11 @@ class UserController extends Controller | |||||||
|             $params['invite_user_id'] = null; |             $params['invite_user_id'] = null; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         if (isset($params['banned']) && (int)$params['banned'] === 1) { | ||||||
|  |             $authService = new AuthService($user); | ||||||
|  |             $authService->removeAllSession(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             $user->update($params); |             $user->update($params); | ||||||
|         } catch (\Exception $e) { |         } catch (\Exception $e) { | ||||||
|   | |||||||
| @@ -39,7 +39,7 @@ class UserController extends Controller | |||||||
|         } |         } | ||||||
|         $authService = new AuthService($user); |         $authService = new AuthService($user); | ||||||
|         return response([ |         return response([ | ||||||
|             'data' => $authService->delSession($request->input('session_id')) |             'data' => $authService->removeSession($request->input('session_id')) | ||||||
|         ]); |         ]); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -84,7 +84,7 @@ class AuthService | |||||||
|         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) |     public function removeSession($sessionId) | ||||||
|     { |     { | ||||||
|         $cacheKey = CacheKey::get("USER_SESSIONS", $this->user->id); |         $cacheKey = CacheKey::get("USER_SESSIONS", $this->user->id); | ||||||
|         $sessions = (array)Cache::get($cacheKey, []); |         $sessions = (array)Cache::get($cacheKey, []); | ||||||
| @@ -95,4 +95,10 @@ class AuthService | |||||||
|         )) return false; |         )) return false; | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public function removeAllSession() | ||||||
|  |     { | ||||||
|  |         $cacheKey = CacheKey::get("USER_SESSIONS", $this->user->id); | ||||||
|  |         return Cache::forget($cacheKey); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user