Browse Source

工程师登录限制

whitefang 1 year ago
parent
commit
e218c4e894
1 changed files with 10 additions and 0 deletions
  1. 10 0
      app/workerapi/logic/LoginLogic.php

+ 10 - 0
app/workerapi/logic/LoginLogic.php

@@ -214,6 +214,14 @@ class LoginLogic extends BaseLogic
      */
     public static function createAuth($response)
     {
+        //判定同一worker_id是否只有一个openid
+        $userAuth = MasterWorkerAuth::where(['worker_id' => $response['user_id']])
+            ->findOrEmpty();
+
+        if(!$userAuth->isEmpty() && !empty($userAuth->openid) && $userAuth->openid != $response['openid']){
+            throw new \Exception('该账号已绑定其他微信');
+        }
+
         //先检查openid是否有记录
         $isAuth = MasterWorkerAuth::where('openid', '=', $response['openid'])->findOrEmpty();
 
@@ -241,6 +249,8 @@ class LoginLogic extends BaseLogic
             }
         }
 
+
+
         //如果没有授权,直接生成一条微信授权记录
         MasterWorkerAuth::create([
             'worker_id' => $response['user_id'],