添加权限检查到管理员登录逻辑
This commit is contained in:
parent
70e58fe432
commit
c7fd3bd5f2
@ -18,7 +18,9 @@ use app\common\logic\BaseLogic;
|
|||||||
use app\common\model\auth\Admin;
|
use app\common\model\auth\Admin;
|
||||||
use app\admin\service\AdminTokenService;
|
use app\admin\service\AdminTokenService;
|
||||||
use app\common\service\FileService;
|
use app\common\service\FileService;
|
||||||
|
use think\facade\Db;
|
||||||
use Webman\Config;
|
use Webman\Config;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录逻辑
|
* 登录逻辑
|
||||||
@ -41,7 +43,12 @@ class LoginLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
$time = time();
|
$time = time();
|
||||||
$admin = Admin::where('account', '=', $params['account'])->find();
|
$admin = Admin::where('account', '=', $params['account'])->find();
|
||||||
|
if(isset($params['is_admin']) &&$params['is_admin'] == 0 &&$admin){
|
||||||
|
$auth_shop=Db::name('user_auth_shop')->where(['admin_id'=>$admin['id'],'status'=>1,'apply_status'=>1,'type'=>2])->find();
|
||||||
|
if(!$auth_shop){
|
||||||
|
throw new BusinessException('该账户没有权限', 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
//用户表登录信息更新
|
//用户表登录信息更新
|
||||||
$admin->login_time = $time;
|
$admin->login_time = $time;
|
||||||
$admin->login_ip = request()->getLocalIp();
|
$admin->login_ip = request()->getLocalIp();
|
||||||
|
@ -58,6 +58,7 @@ class LoginMiddleware implements MiddlewareInterface
|
|||||||
//给request赋值,用于控制器
|
//给request赋值,用于控制器
|
||||||
$request->adminInfo = $adminInfo;
|
$request->adminInfo = $adminInfo;
|
||||||
$request->adminId = $adminInfo['admin_id'] ?? 0;
|
$request->adminId = $adminInfo['admin_id'] ?? 0;
|
||||||
|
$request->supplierId = $adminInfo['supplier_id'] ?? 0;
|
||||||
|
|
||||||
return $handler($request);
|
return $handler($request);
|
||||||
}
|
}
|
||||||
|
5
app/common/cache/AdminTokenCache.php
vendored
5
app/common/cache/AdminTokenCache.php
vendored
@ -9,6 +9,7 @@ use app\common\model\auth\AdminSession;
|
|||||||
use app\common\model\auth\SystemRole;
|
use app\common\model\auth\SystemRole;
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
use support\Cache;
|
use support\Cache;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
class AdminTokenCache extends BaseCache
|
class AdminTokenCache extends BaseCache
|
||||||
{
|
{
|
||||||
@ -65,6 +66,9 @@ class AdminTokenCache extends BaseCache
|
|||||||
$roleName = '系统管理员';
|
$roleName = '系统管理员';
|
||||||
} else {
|
} else {
|
||||||
foreach ($admin['role_id'] as $roleId) {
|
foreach ($admin['role_id'] as $roleId) {
|
||||||
|
if($roleId==1){
|
||||||
|
$auth_shop=Db::name('user_auth_shop')->where(['admin_id'=>$admin['id'],'status'=>1,'apply_status'=>1,'type'=>2])->find();
|
||||||
|
}
|
||||||
$roleName .= $roleLists[$roleId] ?? '';
|
$roleName .= $roleLists[$roleId] ?? '';
|
||||||
$roleName .= '/';
|
$roleName .= '/';
|
||||||
}
|
}
|
||||||
@ -73,6 +77,7 @@ class AdminTokenCache extends BaseCache
|
|||||||
|
|
||||||
$adminInfo = [
|
$adminInfo = [
|
||||||
'admin_id' => $admin->id,
|
'admin_id' => $admin->id,
|
||||||
|
'supplier_id' => $auth_shop?$auth_shop['id']:0,
|
||||||
'root' => $admin->root,
|
'root' => $admin->root,
|
||||||
'name' => $admin->name,
|
'name' => $admin->name,
|
||||||
'account' => $admin->account,
|
'account' => $admin->account,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user