管理员工具
*支持强制用户下线
This commit is contained in:
parent
7a3bf1c135
commit
c77acae424
21
utils/AdminSword.php
Normal file
21
utils/AdminSword.php
Normal 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 '用户不存在';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user