up. 添加客户端锁定日志
This commit is contained in:
parent
77d8262003
commit
19d0992dc6
@ -4,6 +4,7 @@ namespace app\command\admin;
|
|||||||
|
|
||||||
|
|
||||||
use app\entity\SysUserClient;
|
use app\entity\SysUserClient;
|
||||||
|
use app\entity\SysUserClientLog;
|
||||||
use app\service\admin\LoginService;
|
use app\service\admin\LoginService;
|
||||||
use think\console\Command;
|
use think\console\Command;
|
||||||
use think\console\Input;
|
use think\console\Input;
|
||||||
@ -81,13 +82,22 @@ class Worker extends Command
|
|||||||
if($connection->userId) {
|
if($connection->userId) {
|
||||||
$lock_password = $messageJson['data']['lockPassword'] ?? '';
|
$lock_password = $messageJson['data']['lockPassword'] ?? '';
|
||||||
var_dump("锁定客户端/通知全部ws触发锁定操作");
|
var_dump("锁定客户端/通知全部ws触发锁定操作");
|
||||||
SysUserClient::where([
|
$client = SysUserClient::where([
|
||||||
'client_id' => $connection->clientId,
|
'client_id' => $connection->clientId,
|
||||||
'client_name'=> $connection->clientName,
|
'client_name'=> $connection->clientName,
|
||||||
'user_id' => $connection->userId,
|
'user_id' => $connection->userId,
|
||||||
])->update(['is_lock'=>1,'lock_password'=>$lock_password,'lock_time'=>date('Y-m-d H:i:s')]);
|
])->find();
|
||||||
|
$client->update(['is_lock'=>1,'lock_password'=>$lock_password,'lock_time'=>date('Y-m-d H:i:s')]);
|
||||||
// 锁定屏幕
|
// 锁定屏幕
|
||||||
$connection->send(json_encode(['event'=>'LOCK_CLIENT_SCREEN']));
|
$connection->send(json_encode(['event'=>'LOCK_CLIENT_SCREEN']));
|
||||||
|
|
||||||
|
SysUserClientLog::create([
|
||||||
|
'event' => 'UNLOCK',
|
||||||
|
'message'=> "A. 锁定客户端",
|
||||||
|
'data' => ['inputPass'=> $lock_password],
|
||||||
|
'create_time' => date('Y-m-d H:i:s'),
|
||||||
|
'client_data_id'=> $client['id']
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ namespace app\controller\admin\auth;
|
|||||||
use app\BaseController;
|
use app\BaseController;
|
||||||
use app\entity\SysUser;
|
use app\entity\SysUser;
|
||||||
use app\entity\SysUserClient;
|
use app\entity\SysUserClient;
|
||||||
|
use app\entity\SysUserClientLog;
|
||||||
use app\enum\UserLoginEnum;
|
use app\enum\UserLoginEnum;
|
||||||
use app\service\admin\LoginService;
|
use app\service\admin\LoginService;
|
||||||
use think\db\exception\DataNotFoundException;
|
use think\db\exception\DataNotFoundException;
|
||||||
@ -55,14 +56,35 @@ class AuthController extends BaseController
|
|||||||
if($clientModel && $clientModel['is_lock']) {
|
if($clientModel && $clientModel['is_lock']) {
|
||||||
if (empty($clientModel['lock_password'])) {
|
if (empty($clientModel['lock_password'])) {
|
||||||
if(!password_verify($password, $this->auth->getUser()->get('password'))) {
|
if(!password_verify($password, $this->auth->getUser()->get('password'))) {
|
||||||
|
SysUserClientLog::create([
|
||||||
|
'event' => 'UNLOCK_ERROR',
|
||||||
|
'message'=> "1. 尝试解锁,密码错误",
|
||||||
|
'data' => ['inputPass'=> $password],
|
||||||
|
'create_time' => date('Y-m-d H:i:s'),
|
||||||
|
'client_data_id'=> $clientModel['id']
|
||||||
|
]);
|
||||||
return $this->writeError('密码错误');
|
return $this->writeError('密码错误');
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if($clientModel['lock_password'] !== $password) {
|
if($clientModel['lock_password'] !== $password){
|
||||||
|
SysUserClientLog::create([
|
||||||
|
'event' => 'UNLOCK_ERROR',
|
||||||
|
'message'=> "2. 尝试解锁,密码错误",
|
||||||
|
'data' => ['inputPass'=> $password],
|
||||||
|
'create_time' => date('Y-m-d H:i:s'),
|
||||||
|
'client_data_id'=> $clientModel['id']
|
||||||
|
]);
|
||||||
return $this->writeError('密码错误');
|
return $this->writeError('密码错误');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$clientModel->save(['is_lock'=>0,'lock_password'=>'','lock_time'=>null]);
|
$clientModel->save(['is_lock'=>0,'lock_password'=>'','lock_time'=>null]);
|
||||||
|
SysUserClientLog::create([
|
||||||
|
'event' => 'UNLOCK_SUCCESS',
|
||||||
|
'message'=> "0. 解锁成功",
|
||||||
|
'data' => ['inputPass'=> $password],
|
||||||
|
'create_time' => date('Y-m-d H:i:s'),
|
||||||
|
'client_data_id'=> $clientModel['id']
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
14
app/entity/SysUserClientLog.php
Normal file
14
app/entity/SysUserClientLog.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\entity;
|
||||||
|
|
||||||
|
use think\Entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户客户端日志实体
|
||||||
|
* @see \app\model\SysUserClientLog
|
||||||
|
*/
|
||||||
|
class SysUserClientLog extends Entity
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
17
app/model/SysUserClientLog.php
Normal file
17
app/model/SysUserClientLog.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\model;
|
||||||
|
|
||||||
|
use app\BaseModel;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 系统用户客户端日志模型
|
||||||
|
* @property int $id
|
||||||
|
* @property int $user_id
|
||||||
|
* @property string $client_id
|
||||||
|
*/
|
||||||
|
class SysUserClientLog extends BaseModel
|
||||||
|
{
|
||||||
|
protected $name = "sys_user_client_log";
|
||||||
|
protected $pk = "id";
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user