whitefang 1 год назад
Родитель
Сommit
b5bcb9730f
1 измененных файлов с 7 добавлено и 7 удалено
  1. 7 7
      app/api/logic/LoginLogic.php

+ 7 - 7
app/api/logic/LoginLogic.php

@@ -36,11 +36,12 @@ use think\facade\{Db, Config};
  */
 class LoginLogic extends BaseLogic
 {
-
     /**
-     * @notes 账号密码注册
      * @param array $params
-     * @return bool
+     * @return User|\think\Model
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public static function register(array $params)
     {
@@ -49,8 +50,7 @@ class LoginLogic extends BaseLogic
         $passwordSalt = Config::get('project.unique_identification');
         $password = create_password($params['password'], $passwordSalt);
         $avatar = ConfigService::get('default_image', 'user_avatar');
-
-        User::create([
+        $user = User::create([
             'sn' => $userSn,
             'avatar' => $avatar,
             'nickname' => '用户' . $userSn,
@@ -59,7 +59,7 @@ class LoginLogic extends BaseLogic
             'channel' => $params['channel'],
         ]);
 
-        return true;
+        return $user;
     }
 
 
@@ -85,7 +85,7 @@ class LoginLogic extends BaseLogic
             if ($user->isEmpty()) {
                 //直接注册用户
                 $params['channel'] = $params['terminal'];
-                self::register($params);
+                $user = self::register($params);
             }
 
             //更新登录信息