新增控制同一时间同一管理员只能在一个地方登录的功能

修复后台背景插件不作用的BUG
修复后台常规管理,系统配置新增时无法保存的BUG
pull/27/head
Karson 2017-11-30 17:02:34 +08:00
parent dd3f951f13
commit 55473c9029
4 changed files with 21 additions and 4 deletions

View File

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

View File

@ -84,7 +84,7 @@ class Config extends Backend
{ {
if (in_array($params['type'], ['select', 'selects', 'checkbox', 'radio', 'array'])) 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 else
{ {
@ -133,7 +133,7 @@ class Config extends Backend
$value = $row[$v['name']]; $value = $row[$v['name']];
if (is_array($value) && isset($value['field'])) 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 else
{ {

View File

@ -14,6 +14,7 @@ class Auth extends \fast\Auth
protected $requestUri = ''; protected $requestUri = '';
protected $breadcrumb = []; protected $breadcrumb = [];
protected $loginUnique = false; //是否同一账号同一时间只能在一个地方登录
public function __construct() public function __construct()
{ {
@ -153,7 +154,21 @@ class Auth extends \fast\Auth
*/ */
public function isLogin() 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;
} }
/** /**

View File

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