Browse Source

登录注册

15954078560 2 years ago
parent
commit
b9dd88f296
1 changed files with 15 additions and 15 deletions
  1. 15 15
      application/api/controller/User.php

+ 15 - 15
application/api/controller/User.php

@@ -82,22 +82,22 @@ class User extends Api
             $this->error(__('Captcha is incorrect'));
         }
         $user = \app\common\model\User::getByMobile($mobile);
-        if (!$user) {
-            $this->error('用户尚未注册');
-        }
-        if ($user['status'] != 1) {
-            $this->error(__('Account is locked'));
-        }
-//        if ($user) {
-//            if ($user->status != 'normal') {
-//                $this->error(__('Account is locked'));
-//            }
-//            //如果已经有账号则直接登录
-//            $ret = $this->auth->direct($user->id);
-//        } else {
-//            $ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []);
+//        if (!$user) {
+//            $this->error('用户尚未注册');
 //        }
-        $ret = $this->auth->direct($user->id);
+//        if ($user['status'] != 1) {
+//            $this->error(__('Account is locked'));
+//        }
+        if ($user) {
+            if ($user->status != 1) {
+                $this->error(__('Account is locked'));
+            }
+            //如果已经有账号则直接登录
+            $ret = $this->auth->direct($user->id);
+        } else {
+            $ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []);
+        }
+//        $ret = $this->auth->direct($user->id);
         if ($ret) {
             Sms::flush($mobile, 'mobilelogin');
             $data = ['userinfo' => $this->auth->getUserinfo()];