mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]权限节点刷新机制
This commit is contained in:
parent
5a41a72611
commit
5cb2fa8058
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
use app\admin\model\Node;
|
||||||
use controller\BasicAdmin;
|
use controller\BasicAdmin;
|
||||||
use library\Data;
|
use library\Data;
|
||||||
use library\Tools;
|
use library\Tools;
|
||||||
@ -34,6 +35,7 @@ class Index extends BasicAdmin {
|
|||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
|
Node::applyAuthNode();
|
||||||
$list = Db::name('SystemMenu')->field('title,id,pid,url,icon')->order('sort asc,id asc')->where('status', '1')->select();
|
$list = Db::name('SystemMenu')->field('title,id,pid,url,icon')->order('sort asc,id asc')->where('status', '1')->select();
|
||||||
$menus = $this->_filter_menu(Tools::arr2tree($list));
|
$menus = $this->_filter_menu(Tools::arr2tree($list));
|
||||||
$this->assign('title', '后台管理');
|
$this->assign('title', '后台管理');
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
use app\admin\model\Node;
|
||||||
use controller\BasicAdmin;
|
use controller\BasicAdmin;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
|
|
||||||
@ -51,12 +52,9 @@ class Login extends BasicAdmin {
|
|||||||
$user = Db::name('SystemUser')->where('username', $username)->find();
|
$user = Db::name('SystemUser')->where('username', $username)->find();
|
||||||
empty($user) && $this->error('登录账号不存在,请重新输入!');
|
empty($user) && $this->error('登录账号不存在,请重新输入!');
|
||||||
($user['password'] !== md5($password)) && $this->error('登录密码与账号不匹配,请重新输入!');
|
($user['password'] !== md5($password)) && $this->error('登录密码与账号不匹配,请重新输入!');
|
||||||
if (!empty($user['authorize'])) {
|
|
||||||
$authorizeids = explode(',', $user['authorize']);
|
|
||||||
$user['nodes'] = Db::name('SystemAuthNode')->where('auth', 'in', $authorizeids)->column('node');
|
|
||||||
}
|
|
||||||
Db::name('SystemUser')->where('id', $user['id'])->update(['login_at' => ['exp', 'now()'], 'login_num' => ['exp', 'login_num+1']]);
|
Db::name('SystemUser')->where('id', $user['id'])->update(['login_at' => ['exp', 'now()'], 'login_num' => ['exp', 'login_num+1']]);
|
||||||
session('user', $user);
|
session('user', $user);
|
||||||
|
!empty($user['authorize']) && Node::applyAuthNode();
|
||||||
$this->success('登录成功,正在进入系统...', '@admin');
|
$this->success('登录成功,正在进入系统...', '@admin');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace app\admin\model;
|
|||||||
use think\Db;
|
use think\Db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统用户管理控制器
|
* 系统权限节点读取器
|
||||||
* Class Node
|
* Class Node
|
||||||
* @package app\admin\model
|
* @package app\admin\model
|
||||||
* @author Anyon <zoujingli@qq.com>
|
* @author Anyon <zoujingli@qq.com>
|
||||||
@ -25,6 +25,19 @@ use think\Db;
|
|||||||
*/
|
*/
|
||||||
class Node {
|
class Node {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用用户权限节点
|
||||||
|
* @param type $authid
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function applyAuthNode() {
|
||||||
|
if (($authorize = session('user.authorize'))) {
|
||||||
|
$nodes = (array) Db::name('SystemAuthNode')->where('auth', 'in', explode(',', $authorize))->column('node');
|
||||||
|
return session('user.nodes', $nodes);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取系统代码节点
|
* 获取系统代码节点
|
||||||
* @return array
|
* @return array
|
||||||
|
Loading…
x
Reference in New Issue
Block a user