Browse Source

手机号+区号防重复

lizhen_gitee 1 năm trước cách đây
mục cha
commit
e8d629fb7a
2 tập tin đã thay đổi với 12 bổ sung4 xóa
  1. 1 1
      application/api/controller/Sms.php
  2. 11 3
      application/api/controller/User.php

+ 1 - 1
application/api/controller/Sms.php

@@ -51,7 +51,7 @@ class Sms extends Api
         }
         $ipSendTotal = \app\common\model\Sms::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
         if ($ipSendTotal >= 5) {
-            $this->error(__('发送频繁'));
+            $this->error(__('ip发送频繁'));
         }
         if ($event) {
             $userinfo = User::getByMobile($fullmobile);

+ 11 - 3
application/api/controller/User.php

@@ -87,6 +87,7 @@ class User extends Api
         /*if (!Validate::regex($mobile, "^1\d{10}$")) {
             $this->error(__('Mobile is incorrect'));
         }*/
+        $simplemobile = $mobile;
         $mobile = $countrycode.$mobile;
         if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
             $this->error(__('Captcha is incorrect'));
@@ -105,7 +106,7 @@ class User extends Api
 
         } else {
             $extend = [
-//                'register_from' => input('register_from',''),
+                'simplemobile' => $simplemobile,
             ];
             $ret = $this->auth->register('', '', '', $mobile, $extend);
 
@@ -263,6 +264,7 @@ class User extends Api
                 // 取号成功, 执行登录等流程
                 // 用户登录逻辑 === 开始
                 $countrycode = 86;
+                $simplemobile = $mobile;
                 $mobile = $countrycode.$mobile;
                 $user = \app\common\model\User::getByMobile($mobile);
                 if ($user) {
@@ -278,8 +280,10 @@ class User extends Api
 
 
                 } else {
-
-                    $ret = $this->auth->register('', '', '', $mobile, []);
+                    $extend = [
+                        'simplemobile' => $simplemobile,
+                    ];
+                    $ret = $this->auth->register('', '', '', $mobile, $extend);
                     $is_register = 1;
 
                 }
@@ -609,6 +613,7 @@ class User extends Api
         /*if (!Validate::regex($mobile, "^1\d{10}$")) {
             $this->error(__('Mobile is incorrect'));
         }*/
+        $simplemobile = $mobile;
         $mobile = $countrycode.$mobile;
         $result = Sms::check($mobile, $captcha, 'changemobile');
         if (!$result) {
@@ -646,6 +651,7 @@ class User extends Api
         } else {
             $extend = [
                 'ios_user_id' => $iosUserId,
+                'simplemobile' => $simplemobile,
             ];
             $ret = $this->auth->register('', '','', $mobile, $extend);
         }
@@ -677,6 +683,7 @@ class User extends Api
         /*if (!Validate::regex($mobile, "^1\d{10}$")) {
             $this->error(__('Mobile is incorrect'));
         }*/
+        $simplemobile = $mobile;
         $mobile = $countrycode.$mobile;
         $result = Sms::check($mobile, $captcha, 'changemobile');
         if (!$result) {
@@ -718,6 +725,7 @@ class User extends Api
         } else {
             $extend = [
                 'wechat_openid' => $wechatCode['openid'],
+                'simplemobile' => $simplemobile,
             ];
             $ret = $this->auth->register('', '','', $mobile, $extend);
         }