更新用户修改密码
This commit is contained in:
parent
6fa7ff22ca
commit
a2eac95e86
|
@ -38,7 +38,7 @@ class UserController extends BaseApiController
|
||||||
public function changeMobile(): Json
|
public function changeMobile(): Json
|
||||||
{
|
{
|
||||||
$params = (new UserValidate())->post()->goCheck('changeMobile');
|
$params = (new UserValidate())->post()->goCheck('changeMobile');
|
||||||
$result = UserLogic::changeMobile($params,$this->userId);
|
$result = UserLogic::changeMobile($params, $this->userId);
|
||||||
if($result) {
|
if($result) {
|
||||||
return $this->success('修改成功');
|
return $this->success('修改成功');
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class LoginJwtMiddleware
|
||||||
|
|
||||||
//不直接判断$isNotNeedLogin结果,使不需要登录的接口通过,为了兼容某些接口可以登录或不登录访问
|
//不直接判断$isNotNeedLogin结果,使不需要登录的接口通过,为了兼容某些接口可以登录或不登录访问
|
||||||
if (empty($token) && !$isNotNeedLogin) {
|
if (empty($token) && !$isNotNeedLogin) {
|
||||||
return JsonService::fail('请求参数缺token', [], 0, 0);
|
return JsonService::fail('请求参数缺少token', [], 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$isNotNeedLogin) {
|
if (!$isNotNeedLogin) {
|
||||||
|
|
|
@ -29,16 +29,6 @@ class LoginLogic extends BaseLogic
|
||||||
$avatar = env('project.web_domain').'/'.ConfigService::get('default_image', 'user_avatar');
|
$avatar = env('project.web_domain').'/'.ConfigService::get('default_image', 'user_avatar');
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
//添加到管理员表
|
|
||||||
$admin = Admin::create([
|
|
||||||
'root' => 0,
|
|
||||||
'name' => '用户'.$params['phone'],
|
|
||||||
'avatar' => empty($params['avatar']) ? $avatar : $params['avatar'],
|
|
||||||
'account' => $params['phone'],
|
|
||||||
'password' => $adminPassword,
|
|
||||||
'multipoint_login' => 1,
|
|
||||||
'disable' => 0
|
|
||||||
]);
|
|
||||||
//添加到用户表
|
//添加到用户表
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'admin_id' => $admin['id'],
|
'admin_id' => $admin['id'],
|
||||||
|
|
|
@ -68,10 +68,6 @@ class UserLogic extends BaseLogic
|
||||||
public static function changeMobile(array $params,int $uid): bool
|
public static function changeMobile(array $params,int $uid): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$user = User::field('admin_id')->where('id',$uid)->findOrEmpty();
|
|
||||||
if($user->isEmpty()){
|
|
||||||
throw new \Exception('数据错误');
|
|
||||||
}
|
|
||||||
// 校验短信
|
// 校验短信
|
||||||
$checkSmsCode = (new SmsDriver())->verify($params['phone'], $params['code'], NoticeEnum::CHANGE_MOBILE_CAPTCHA);
|
$checkSmsCode = (new SmsDriver())->verify($params['phone'], $params['code'], NoticeEnum::CHANGE_MOBILE_CAPTCHA);
|
||||||
if (!$checkSmsCode) {
|
if (!$checkSmsCode) {
|
||||||
|
@ -81,10 +77,6 @@ class UserLogic extends BaseLogic
|
||||||
'id' => $uid,
|
'id' => $uid,
|
||||||
'phone' => $params['phone'],
|
'phone' => $params['phone'],
|
||||||
]);
|
]);
|
||||||
Admin::update([
|
|
||||||
'id' => $user['admin_id'],
|
|
||||||
'account' => $params['phone']
|
|
||||||
]);
|
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
|
|
Loading…
Reference in New Issue