Browse Source

接口基础方法

lizhen_gitee 1 year ago
parent
commit
516c98bdde

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

@@ -29,10 +29,6 @@ class User extends Api
     {
         parent::_initialize();
 
-        if (!Config::get('fastadmin.usercenter')) {
-            $this->error(__('User center already closed'));
-        }
-
     }
 
     /**

+ 11 - 2
application/common/controller/Api.php

@@ -129,12 +129,12 @@ class Api
                 $this->error(__('Please login first'), null, 401);
             }
             // 判断是否需要验证权限
-            if (!$this->auth->match($this->noNeedRight)) {
+            /*if (!$this->auth->match($this->noNeedRight)) {
                 // 判断控制器和方法判断是否有对应权限
                 if (!$this->auth->check($path)) {
                     $this->error(__('You have no permission'), null, 403);
                 }
-            }
+            }*/
         } else {
             // 如果有传递token才验证是否登录状态
             if ($token) {
@@ -173,6 +173,9 @@ class Api
      */
     protected function success($msg = '', $data = null, $code = 1, $type = null, array $header = [])
     {
+        if($msg == 1){
+            $msg = 'success';
+        }
         if(empty($msg)){
             $msg = '操作成功';
         }
@@ -411,6 +414,12 @@ class Api
         $redis = new Redis();
         $redisconfig = config("redis");
         $redis->connect($redisconfig["host"], $redisconfig["port"]);
+        if ($redisconfig['redis_pwd']) {
+            $redis->auth($redisconfig['redis_pwd']);
+        }
+        if($redisconfig['redis_selectdb'] > 0){
+            $redis->select($redisconfig['redis_selectdb']);
+        }
         $check = $redis->exists($key);
         if ($check) {
             $redis->incr($key);

+ 3 - 0
application/config.php

@@ -343,6 +343,9 @@ return [
         'host'     => '127.0.0.1',
         // 端口
         'port'      => 6379,
+
+        'redis_pwd' => '',
+        'redis_selectdb' => 0,
     ],
 
     // 运营商一键登录