管理员权限从用户改成以组的形式

master
zhengyongxing 5 years ago
parent 19cbae833a
commit b87dec3aee

@ -72,6 +72,7 @@ class MemberModel extends Model {
$this->save($data);
$adminData = getAdminData($user['uid']);
$groupId = getGameGroup($user['uid']);
/* 记录登录SESSION和COOKIES */
$auth = array(
@ -86,6 +87,7 @@ class MemberModel extends Model {
$expireTime = 3600;
ini_set('session.gc_maxlifetime', $expireTime);
ini_set('session.cookie_lifetime', $expireTime);
session('user_group_id',$groupId);
session('user_auth', $auth);
session('user_auth_sign', data_auth_sign($auth));
session('user_auth_expire', time());

@ -32,6 +32,7 @@ function is_login()
if (time() - intval(session('user_auth_expire')) > $expire) { // 过期正则直接去除掉session 并且返回false
session('user_auth', null);
session('user_auth_sign', null);
session('user_group_id', null);
return 0;
} else {
session('user_auth_expire', time() + $expire);
@ -48,7 +49,9 @@ function is_login()
function is_administrator($uid = null)
{
$uid = is_null($uid) ? is_login() : $uid;
return $uid && (intval($uid) === C('USER_ADMINISTRATOR'));
return $uid && (session('user_group_id') == 1);
// (intval($uid) === C('USER_ADMINISTRATOR'));
}
/**
@ -1472,4 +1475,12 @@ function getPromoteCompanyName($companyId)
function getGameTypes()
{
return M('game_type', 'tab_')->field('id, type_name')->where(['status' => 1])->select();
}
function getGameGroup($uid) {
$groupId = M('auth_group_access')->field('group_id')->where(['uid'=>$uid])->find();
return $groupId['group_id']?$groupId['group_id']:0;
}
Loading…
Cancel
Save