改进 Token 吊销
This commit is contained in:
parent
bf25d56705
commit
daff4a9e46
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\AccessToken;
|
|
||||||
use App\Models\Host;
|
use App\Models\Host;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
@ -62,9 +61,9 @@ public function handle()
|
|||||||
'suspended_at' => now()
|
'suspended_at' => now()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->info('正在清除 Token.');
|
$this->info('正在吊销所有 Token...');
|
||||||
|
|
||||||
AccessToken::where('user_id', $user_id)->delete();
|
$user->tokens()->delete();
|
||||||
|
|
||||||
$this->info('封禁用户成功。');
|
$this->info('封禁用户成功。');
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public function index(Request $request)
|
|||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
if ($user->banned_at !== null) {
|
if ($user->banned_at !== null) {
|
||||||
$user->tokens()->delete();
|
// $user->tokens()->delete();
|
||||||
return redirect()->route('banned');
|
return redirect()->route('banned');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user