浏览代码

实名认证的功能限制

lizhen_gitee 1 年之前
父节点
当前提交
50e7ed2b04

+ 4 - 0
application/api/controller/Relation.php

@@ -63,6 +63,10 @@ class Relation extends Api
             $this->error('不能跟自己建立关系');
         }
 
+        if(!$this->user_auth_limit()){
+            $this->error('请先完成实名认证');
+        }
+
         //关系检测
         $relation_id    = input('relation_id','');
         $relation = Db::name('relation')->where('id',$relation_id)->find();

+ 4 - 0
application/api/controller/Topicdongtai.php

@@ -29,6 +29,10 @@ class Topicdongtai extends Api
             $this->error(__('Invalid parameters'));
         }
 
+        if(!$this->user_auth_limit()){
+            $this->error('请先完成实名认证');
+        }
+
         //关键字替换
         $content = Keyworld::sensitive($content);
 

+ 7 - 5
application/common/controller/Api.php

@@ -508,16 +508,18 @@ class Api
         return 0;
     }
 
-    //实名认证限制
-    //true  不需要实名认证
-    //false 需要实名认证
+    //实名认证限制功能
+    //true  不需要实名认证,不受限
+    //false 需要实名认证,受限
     protected function user_auth_limit(){
         $user_auth_switch = config('site.user_auth_switch');
         if($user_auth_switch != 1){
-            return true;
+            return true;  //没开,不受限
         }else{
             if($this->auth->idcard_status == 1){
-                return true;
+                return true; //已实名,不受限
+            }else{
+                return false;
             }
         }
 

+ 21 - 0
application/common/library/Auth.php

@@ -709,9 +709,30 @@ class Auth
         //用户权限
         $userinfo['power'] = Db::name('user_power')->where('user_id',$this->id)->find();
 
+        //用户受到实名限制,是否能主动发起聊天
+        $userinfo['im_auth_limit'] = $this->im_auth_limit() ? 1 : 0;
+
         return $userinfo;
     }
 
+    //实名认证限制功能
+    //true  不需要实名认证,不受限
+    //false 需要实名认证,受限
+    private function im_auth_limit(){
+        $user_auth_switch = config('site.user_auth_switch');
+        if($user_auth_switch != 1){
+            return true;  //没开,不受限
+        }else{
+            if($this->idcard_status == 1){
+                return true; //已实名,不受限
+            }else{
+                return false;
+            }
+        }
+
+        return false;
+    }
+
     /**
      * 获取会员组别规则列表
      * @return array