登录接口返回是否新用户

This commit is contained in:
luofei 2024-01-27 16:11:09 +08:00
parent dddfaada87
commit aeeddbd222

View File

@ -734,7 +734,10 @@ class Auth extends BaseController
if (!$sms_code && !env('APP_DEBUG')) return app('json')->fail('验证码不正确');
$user = $repository->accountByUser($data['phone']);
$auth = $this->parseAuthToken($data['auth_token']);
if (!$user) $user = $repository->registr($data['phone'], null, $data['user_type']);
if (!$user) {
$isNewUser = true;
$user = $repository->registr($data['phone'], null, $data['user_type']);
}
if ($auth && !$user['wechat_user_id']) {
$repository->syncBaseAuth($auth, $user);
}
@ -744,7 +747,7 @@ class Auth extends BaseController
$tokenInfo = $repository->createToken($user);
$repository->loginAfter($user);
return app('json')->success($repository->returnToken($user, $tokenInfo));
return app('json')->success(array_merge(['is_new_user' => $isNewUser ?? false], $repository->returnToken($user, $tokenInfo)));
}
public function changePassword(ChangePasswordValidate $validate, UserRepository $repository)