管理员工具

*支持强制用户下线
This commit is contained in:
Chenx221 2024-03-23 14:28:03 +08:00
parent 7a3bf1c135
commit c77acae424
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021

21
utils/AdminSword.php Normal file
View File

@ -0,0 +1,21 @@
<?php
namespace app\utils;
use app\models\User;
use Yii;
class AdminSword
{
public static function forceUserLogout($id):string
{
$user = User::findOne($id);
if ($user) {
$user->auth_key = Yii::$app->security->generateRandomString();
$user->save(false);
return '用户已被强制下线';
} else {
return '用户不存在';
}
}
}