Compare commits
2 Commits
6fa7ff22ca
...
5e8ae28ea2
Author | SHA1 | Date |
---|---|---|
yaooo | 5e8ae28ea2 | |
yaooo | a2eac95e86 |
|
@ -38,7 +38,7 @@ class UserController extends BaseApiController
|
|||
public function changeMobile(): Json
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('changeMobile');
|
||||
$result = UserLogic::changeMobile($params,$this->userId);
|
||||
$result = UserLogic::changeMobile($params, $this->userId);
|
||||
if($result) {
|
||||
return $this->success('修改成功');
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class LoginJwtMiddleware
|
|||
|
||||
//不直接判断$isNotNeedLogin结果,使不需要登录的接口通过,为了兼容某些接口可以登录或不登录访问
|
||||
if (empty($token) && !$isNotNeedLogin) {
|
||||
return JsonService::fail('请求参数缺token', [], 0, 0);
|
||||
return JsonService::fail('请求参数缺少token', [], 0, 0);
|
||||
}
|
||||
|
||||
if (!$isNotNeedLogin) {
|
||||
|
|
|
@ -29,19 +29,9 @@ class LoginLogic extends BaseLogic
|
|||
$avatar = env('project.web_domain').'/'.ConfigService::get('default_image', 'user_avatar');
|
||||
Db::startTrans();
|
||||
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([
|
||||
'admin_id' => $admin['id'],
|
||||
'admin_id' => 0,
|
||||
'phone' => $params['phone'],
|
||||
'nick_name' => '用户'.$params['phone'],
|
||||
'password' => $userPassword,
|
||||
|
|
|
@ -68,10 +68,6 @@ class UserLogic extends BaseLogic
|
|||
public static function changeMobile(array $params,int $uid): bool
|
||||
{
|
||||
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);
|
||||
if (!$checkSmsCode) {
|
||||
|
@ -81,10 +77,6 @@ class UserLogic extends BaseLogic
|
|||
'id' => $uid,
|
||||
'phone' => $params['phone'],
|
||||
]);
|
||||
Admin::update([
|
||||
'id' => $user['admin_id'],
|
||||
'account' => $params['phone']
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
|
|
Loading…
Reference in New Issue