Browse Source

填写用户身份信息

master
wanghongjun 3 years ago
parent
commit
b9926b8e5a
  1. 14
      app/api/controller/User.php
  2. 21
      app/api/model/User.php

14
app/api/controller/User.php

@ -107,4 +107,18 @@ class User extends Controller
}
return $this->renderSuccess('恭喜您,密码设置成功');
}
/**
* 填写用户身份信息
* @return Json
* @throws BaseException
*/
public function userAuthentication(): Json
{
$model = new UserModel;
if (!$model->saveAuthenticationData($this->postForm())) {
return $this->renderSuccess($model->getError() ?: '操作失败');
}
return $this->renderSuccess('恭喜您,身份填写成功');
}
}

21
app/api/model/User.php

@ -133,12 +133,29 @@ class User extends UserModel
* @return bool
* @throws BaseException
*/
public function savePassword(array $data): bool
public function savePassword(array $form): bool
{
// 当前登录的用户信息
$userInfo = UserService::getCurrentLoginUser(true);
// 默认数据
$data['password'] = encryption_hash($data['password']);
$data['password'] = encryption_hash($form['password']);
// 更新用户记录
return $userInfo->save($data);
}
/**
* 填写身份信息
* @param $form
* @return bool
* @throws BaseException
*/
public function saveAuthenticationData($form): bool
{
// 当前登录的用户信息
$userInfo = UserService::getCurrentLoginUser(true);
// 默认数据
$data['id_no'] = $form['id_no'];
$data['real_name'] = $form['real_name'];
// 更新用户记录
return $userInfo->save($data);
}

Loading…
Cancel
Save