数智员工免密登录
This commit is contained in:
@@ -102,15 +102,27 @@ class PasswordLoginController extends BaseController
|
||||
* @param string $account 账号(手机号)
|
||||
* @param string $password 密码(可能是加密后的)
|
||||
* @param string $typeId 登录IP
|
||||
* @param string $deviceId 本地设备imei
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function doLogin(string $account, string $password, int $typeId): array
|
||||
protected function doLogin(string $account, string $password, int $typeId, string $deviceId): array
|
||||
{
|
||||
// 获取用户信息
|
||||
$member = $this->getUser($account, $password, $typeId);
|
||||
$deviceTotal = Db::name('device')->where(['companyId' => $member['companyId'],'deleteTime' => 0])->count();
|
||||
|
||||
//更新设备imei
|
||||
if ($typeId == 2 && !empty($deviceId)){
|
||||
$deviceUser = Db::name('device_user')->where(['companyId' => $member['companyId'],'userId' => $member['id'],'deleteTime' => 0])->find();
|
||||
if (!empty($deviceUser)){
|
||||
$s2_device = Db::table('s2_device')->where(['companyId' => $member['companyId'],'deleteTime' => 0,'id' => $deviceUser])->find();
|
||||
if (!empty($s2_device) && empty($s2_device['deviceImei'])){
|
||||
Db::table('s2_device')->where(['id' => $s2_device['id']])->update(['deviceImei' => $deviceId,'updateTime' => time()]);
|
||||
Db::name('device')->where(['id' => $s2_device['id']])->update(['deviceImei' => $deviceId,'updateTime' => time()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 生成JWT令牌
|
||||
@@ -126,34 +138,16 @@ class PasswordLoginController extends BaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$params = $this->request->only(['account', 'password', 'typeId']);
|
||||
$params = $this->request->only(['account', 'password', 'typeId','deviceId']);
|
||||
try {
|
||||
$userData = $this->dataValidate($params)->doLogin(
|
||||
$params['account'],
|
||||
$params['password'],
|
||||
$params['typeId']
|
||||
$params['typeId'],
|
||||
$params['deviceId']
|
||||
);
|
||||
//同时登录客服系统
|
||||
/* if (!empty($userData['member']['passwordLocal'])){
|
||||
$params = [
|
||||
'grant_type' => 'password',
|
||||
'username' => $userData['member']['account'],
|
||||
'password' => localDecrypt($userData['member']['passwordLocal'])
|
||||
];
|
||||
// 调用登录接口获取token
|
||||
$headerData = ['client:kefu-client'];
|
||||
$header = setHeader($headerData, '', 'plain');
|
||||
$result = requestCurl('https://s2.siyuguanli.com:9991/token', $params, 'POST', $header);
|
||||
$token = handleApiResponse($result);
|
||||
$userData['kefuData']['token'] = $token;
|
||||
if (isset($token['access_token']) && !empty($token['access_token'])) {
|
||||
$headerData = ['client:kefu-client'];
|
||||
$header = setHeader($headerData, $token['access_token']);
|
||||
$result = requestCurl( 'https://s2.siyuguanli.com:9991/api/account/self', [], 'GET', $header,'json');
|
||||
$self = handleApiResponse($result);
|
||||
$userData['kefuData']['self'] = $self;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
return ResponseHelper::success($userData, '登录成功');
|
||||
} catch (Exception $e) {
|
||||
return ResponseHelper::error($e->getMessage(), $e->getCode());
|
||||
|
||||
Reference in New Issue
Block a user