|
@@ -190,12 +190,14 @@ class CompanyStaff extends Backend
|
|
|
$row->validateFailException(true)->validate($validate);
|
|
|
}
|
|
|
//密码和盐
|
|
|
- if (isset($params['password'])) {
|
|
|
+ if ($params['password']) {
|
|
|
if (!Validate::is($params['password'], "/^[\S]{6,30}$/")) {
|
|
|
$this->error('请输入6-30位密码');
|
|
|
}
|
|
|
$params['salt'] = Random::alnum();
|
|
|
$params['password'] = md5(md5($params['password']) . $params['salt']);
|
|
|
+ }else {
|
|
|
+ unset($params['password'], $params['salt']);
|
|
|
}
|
|
|
//检查
|
|
|
$check2 = Db::name('company_staff')->where('id','neq',$ids)->where('mobile',$params['mobile'])->find();
|
|
@@ -209,19 +211,20 @@ class CompanyStaff extends Backend
|
|
|
Db::startTrans();
|
|
|
//保存
|
|
|
$result = $row->allowField(true)->save($params);
|
|
|
- if ($result == false) {
|
|
|
+ if ($result === false) {
|
|
|
Db::rollback();
|
|
|
$this->error(__('No rows were updated'));
|
|
|
}
|
|
|
|
|
|
+ $row = $this->model->get($ids);
|
|
|
//同步到admin
|
|
|
$admin_info = Db::name('admin')->where('staff_id',$ids)->find();
|
|
|
if(!empty($admin_info)){
|
|
|
$admin = [
|
|
|
'username' => $params['mobile'],
|
|
|
'nickname' => $params['truename'],
|
|
|
- 'password' => $params['password'],
|
|
|
- 'salt' => $params['salt'],
|
|
|
+ 'password' => $row['password'],
|
|
|
+ 'salt' => $row['salt'],
|
|
|
'mobile' => $params['mobile'],
|
|
|
'updatetime' => time(),
|
|
|
];
|
|
@@ -236,8 +239,8 @@ class CompanyStaff extends Backend
|
|
|
$admin = [
|
|
|
'username' => $params['mobile'],
|
|
|
'nickname' => $params['truename'],
|
|
|
- 'password' => $params['password'],
|
|
|
- 'salt' => $params['salt'],
|
|
|
+ 'password' => $row['password'],
|
|
|
+ 'salt' => $row['salt'],
|
|
|
|
|
|
'avatar' => '/assets/img/avatar.png',
|
|
|
'mobile' => $params['mobile'],
|