Kaynağa Gözat

新增控制同一时间同一管理员只能在一个地方登录的功能
修复后台背景插件不作用的BUG
修复后台常规管理,系统配置新增时无法保存的BUG

Karson 7 yıl önce
ebeveyn
işleme
55473c9029

+ 2 - 0
application/admin/controller/Index.php

@@ -87,6 +87,8 @@ class Index extends Backend
         {
             $this->redirect($url);
         }
+        $background = cdnurl("/assets/img/loginbg.jpg");
+        $this->view->assign('background', $background);
         \think\Hook::listen("login_init", $this->request);
         return $this->view->fetch();
     }

+ 2 - 2
application/admin/controller/general/Config.php

@@ -84,7 +84,7 @@ class Config extends Backend
                 {
                     if (in_array($params['type'], ['select', 'selects', 'checkbox', 'radio', 'array']))
                     {
-                        $params['content'] = ConfigModel::decode($params['content']);
+                        $params['content'] = json_encode(ConfigModel::decode($params['content']), JSON_UNESCAPED_UNICODE);
                     }
                     else
                     {
@@ -133,7 +133,7 @@ class Config extends Backend
                         $value = $row[$v['name']];
                         if (is_array($value) && isset($value['field']))
                         {
-                            $value = json_encode(\app\common\model\Config::getArrayData($value), JSON_UNESCAPED_UNICODE);
+                            $value = json_encode(ConfigModel::getArrayData($value), JSON_UNESCAPED_UNICODE);
                         }
                         else
                         {

+ 16 - 1
application/admin/library/Auth.php

@@ -14,6 +14,7 @@ class Auth extends \fast\Auth
 
     protected $requestUri = '';
     protected $breadcrumb = [];
+    protected $loginUnique = false; //是否同一账号同一时间只能在一个地方登录
 
     public function __construct()
     {
@@ -153,7 +154,21 @@ class Auth extends \fast\Auth
      */
     public function isLogin()
     {
-        return Session::get('admin') ? true : false;
+        $admin = Session::get('admin');
+        if (!$admin)
+        {
+            return false;
+        }
+        //判断是否同一时间同一账号只能在一个地方登录
+        if ($this->loginUnique)
+        {
+            $my = Admin::get($admin->id);
+            if (!$my || $my->token != $admin->token)
+            {
+                return false;
+            }
+        }
+        return true;
     }
 
     /**

+ 1 - 1
application/admin/view/index/login.html

@@ -6,7 +6,7 @@
         <style type="text/css">
             body {
                 color:#999;
-                background:url('__CDN__/assets/img/loginbg.jpg');
+                background:url('{$background}');
                 background-size:cover;
             }
             a {