缓存用户权限
This commit is contained in:
parent
7eeade987a
commit
04d942c7db
@ -9,9 +9,11 @@ use catchAdmin\user\request\CreateRequest;
|
|||||||
use catchAdmin\user\request\UpdateRequest;
|
use catchAdmin\user\request\UpdateRequest;
|
||||||
use catcher\base\CatchController;
|
use catcher\base\CatchController;
|
||||||
use catcher\CatchAuth;
|
use catcher\CatchAuth;
|
||||||
|
use catcher\CatchCacheKeys;
|
||||||
use catcher\CatchResponse;
|
use catcher\CatchResponse;
|
||||||
use catcher\Tree;
|
use catcher\Tree;
|
||||||
use catcher\Utils;
|
use catcher\Utils;
|
||||||
|
use think\facade\Cache;
|
||||||
|
|
||||||
class User extends CatchController
|
class User extends CatchController
|
||||||
{
|
{
|
||||||
@ -50,7 +52,11 @@ class User extends CatchController
|
|||||||
|
|
||||||
$roles = $user->getRoles();
|
$roles = $user->getRoles();
|
||||||
|
|
||||||
$user->permissions = Permissions::getCurrentUserPermissions();
|
$permissionIds = $user->getPermissionsBy();
|
||||||
|
// 缓存用户权限
|
||||||
|
Cache::set(CatchCacheKeys::USER_PERMISSIONS . $user->id, $permissionIds);
|
||||||
|
|
||||||
|
$user->permissions = Permissions::getCurrentUserPermissions($permissionIds);
|
||||||
|
|
||||||
$user->roles = $roles;
|
$user->roles = $roles;
|
||||||
|
|
||||||
|
16
extend/catcher/CatchCacheKeys.php
Normal file
16
extend/catcher/CatchCacheKeys.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @filename CacheKeys.php
|
||||||
|
* @createdAt 2020/1/17
|
||||||
|
* @project https://github.com/yanwenwu/catch-admin
|
||||||
|
* @document http://doc.catchadmin.com
|
||||||
|
* @author JaguarJack <njphper@gmail.com>
|
||||||
|
* @copyright By CatchAdmin
|
||||||
|
* @license https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt
|
||||||
|
*/
|
||||||
|
namespace catcher;
|
||||||
|
|
||||||
|
class CatchCacheKeys
|
||||||
|
{
|
||||||
|
public const USER_PERMISSIONS = 'user_permissions_';
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user