From 8126c171972484ce18c2a9eabc28860888484217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sat, 12 Nov 2022 18:12:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E8=B5=84?= =?UTF-8?q?=E6=96=99=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/api/Wxapp.php | 6 +++--- app/data/service/UserAdminService.php | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/data/controller/api/Wxapp.php b/app/data/controller/api/Wxapp.php index c0f80d273..86e68152e 100644 --- a/app/data/controller/api/Wxapp.php +++ b/app/data/controller/api/Wxapp.php @@ -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'])) { diff --git a/app/data/service/UserAdminService.php b/app/data/service/UserAdminService.php index fc0b92f07..0a1534913 100644 --- a/app/data/service/UserAdminService.php +++ b/app/data/service/UserAdminService.php @@ -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);