分离后台和用户中心登录状态

This commit is contained in:
2020-04-27 08:10:23 +08:00
parent ab34ae6458
commit 246c95d956
6 changed files with 38 additions and 23 deletions

View File

@@ -13,16 +13,29 @@ use think\facade\Session;
use think\facade\Config;
/**
*
* @title 检查登录状态
*/
function is_login() {
$user = Session::get('userInfo');
return isset($user['uid']) ? $user['uid'] : false;
if(strpos(Request::controller(), ".")){
list($module, $controller) = explode(".", Request::controller());
}else{
$module = "";
}
$user = Session::get(strtolower($module) . 'Info');
return $user['uid'];
}
/**
* @title 检查是否为超级管理员
*/
function is_administrator() {
$user = Session::get('userInfo');
return (isset($user['uid']) && (int) $user['uid'] === (int) env('rootuid')) ? true : false;
if(strpos(Request::controller(), ".")){
list($module, $controller) = explode(".", Request::controller());
}else{
$module = "";
}
$user = Session::get(strtolower($module) . 'Info');
return (int) $user['uid'] === (int) env('rootuid') ? true : false;
}
function form($field = [], $data = []) {