Skip to content

Commit

Permalink
fix 修改用户更新个人资料过滤不存在的字段、修复手机号码验证传递null会报错的问题 (#283)
Browse files Browse the repository at this point in the history
* 修复因 storage_mode是int类型获取文件系统不正确导致无法删除OSS或其他文件系统文件

* fix

* 修改用户更新个人资料过滤不存在的字段、修复手机号码验证传递null会报错的问题
  • Loading branch information
zazi523623 authored Jun 20, 2024
1 parent 573bc93 commit b3c98d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/System/Listener/ValidatorFactoryResolvedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public function process(object $event): void
$validatorFactory = $event->validatorFactory;

$validatorFactory->extend('phone_number', function (string $attribute, mixed $value, array $parameters, Validator $validator): bool {
if (! $value) {
return false;
}

return (bool) preg_match('/^1[3-9]\d{9}$/', $value);
});
}
Expand Down
9 changes: 3 additions & 6 deletions app/System/Service/SystemUserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,11 @@ public function updateInfo(array $params): bool
return false;
}

$model = $this->mapper->getModel()::find($params['id']);
$id = $params['id'];
unset($params['id'], $params['password']);
foreach ($params as $key => $param) {
$model[$key] = $param;
}
$this->clearCache((string) $id);

$this->clearCache((string) $model['id']);
return $model->save();
return $this->mapper->update($id, $params);
}

/**
Expand Down

0 comments on commit b3c98d5

Please sign in to comment.