mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
user_can() cancel use set cache
This commit is contained in:
@@ -958,7 +958,7 @@ function clear_user_cache($uid, $passkey = '')
|
||||
\Nexus\Database\NexusDB::cache_del("user_{$uid}_content");
|
||||
\Nexus\Database\NexusDB::cache_del("user_{$uid}_roles");
|
||||
\Nexus\Database\NexusDB::cache_del("announce_user_passkey_$uid");//announce.php
|
||||
\Nexus\Database\NexusDB::cache_del(\App\Models\Setting::DIRECT_PERMISSION_SET_KEY_PREFIX . $uid);
|
||||
\Nexus\Database\NexusDB::cache_del(\App\Models\Setting::DIRECT_PERMISSION_CACHE_KEY_PREFIX . $uid);
|
||||
if ($passkey) {
|
||||
\Nexus\Database\NexusDB::cache_del('user_passkey_'.$passkey.'_content');//announce.php
|
||||
}
|
||||
@@ -977,25 +977,6 @@ function clear_staff_message_cache()
|
||||
\App\Repositories\MessageRepository::updateStaffMessageCountCache(false);
|
||||
}
|
||||
|
||||
function build_class_permission_cache()
|
||||
{
|
||||
$redis = \Nexus\Database\NexusDB::redis();
|
||||
$results = [];
|
||||
$settings = get_setting_from_db("authority");
|
||||
foreach (\App\Models\User::$classes as $class => $info) {
|
||||
foreach ($settings as $permission => $minClass) {
|
||||
if ($class >= $minClass) {
|
||||
$results[$class][] = $permission;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($results as $class => $permissions) {
|
||||
$classKey = \App\Models\Setting::CLASS_PERMISSION_SET_KEY_PREFIX . $class;
|
||||
$redis->del($classKey);
|
||||
$redis->sAddArray($classKey, $permissions);
|
||||
}
|
||||
}
|
||||
|
||||
function user_can($permission, $fail = false, $uid = 0, $class = null): bool
|
||||
{
|
||||
$log = "permission: $permission, fail: $fail, user: $uid";
|
||||
@@ -1022,7 +1003,7 @@ function user_can($permission, $fail = false, $uid = 0, $class = null): bool
|
||||
$userCanCached[$permission][$uid] = true;
|
||||
return true;
|
||||
}
|
||||
$userAllPermissions = \App\Repositories\ToolRepository::listUserAllPermissions($uid, $class);
|
||||
$userAllPermissions = \App\Repositories\ToolRepository::listUserAllPermissions($uid);
|
||||
$result = isset($userAllPermissions[$permission]);
|
||||
if ($sequence == 0) {
|
||||
$sequence++;
|
||||
|
||||
Reference in New Issue
Block a user