修改用户资料更新

This commit is contained in:
邹景立 2022-11-12 18:12:23 +08:00
parent ccd6d15bfb
commit 8126c17197
2 changed files with 8 additions and 4 deletions

View File

@ -43,10 +43,10 @@ class Wxapp extends Controller
*/
protected function initialize()
{
$option = sysdata('wxapp');
$wxapp = sysdata('wxapp');
$this->config = [
'appid' => $option['appid'] ?? '',
'appsecret' => $option['appkey'] ?? '',
'appid' => $wxapp['appid'] ?? '',
'appsecret' => $wxapp['appkey'] ?? '',
'cache_path' => with_path('runtime/wechat'),
];
if (empty(UserAdminService::TYPES[$this->type]['auth'])) {

View File

@ -61,8 +61,12 @@ class UserAdminService extends Service
*/
public static function set($map, array $data, string $type, bool $force = false): array
{
unset($data['id'], $data['deleted'], $data['create_at']);
$user = DataUser::mk()->where($map)->where(['deleted' => 0])->findOrEmpty();
unset($data['id'], $data['deleted'], $data['create_at']);
// 不更新无效的用户字段
if (!empty($user['nickname']) && $data['nickname'] === '微信用户') {
unset($data['nickname'], $data['headimg']);
}
if (!$user->save($data)) throw new Exception("更新用户资料失败!");
// 刷新用户认证令牌
if ($force) UserTokenService::token($user['id'], $type);