mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
init user token permission allowed when upgrade
This commit is contained in:
@@ -101,13 +101,15 @@ class Setting extends NexusModel
|
||||
return $value;
|
||||
}
|
||||
|
||||
public static function updateUserTokenPermissionAllowedCache(): void
|
||||
public static function updateUserTokenPermissionAllowedCache(array $allowed = []): void
|
||||
{
|
||||
$redis = NexusDB::redis();
|
||||
$key = self::USER_TOKEN_PERMISSION_ALLOWED_CACHE_KRY;
|
||||
$redis->del($key);
|
||||
//must not use cache
|
||||
$allowed = self::getFromDb("permission.user_token_allowed");
|
||||
if (empty($allowed)) {
|
||||
$allowed = self::getFromDb("permission.user_token_allowed");
|
||||
}
|
||||
if (!empty($allowed)) {
|
||||
$redis->sAdd($key, ...$allowed);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,11 @@ class TokenRepository extends BaseRepository
|
||||
RoutePermissionEnum::USER_VIEW->value,
|
||||
];
|
||||
|
||||
public static function listUserTokenPermissions(): array
|
||||
public static function listUserTokenPermissions(bool $format = true): array
|
||||
{
|
||||
if (!$format) {
|
||||
return self::$userTokenPermissions;
|
||||
}
|
||||
return self::formatPermissions(self::$userTokenPermissions);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ use App\Repositories\BonusRepository;
|
||||
use App\Repositories\ExamRepository;
|
||||
use App\Repositories\SearchBoxRepository;
|
||||
use App\Repositories\TagRepository;
|
||||
use App\Repositories\TokenRepository;
|
||||
use App\Repositories\ToolRepository;
|
||||
use App\Repositories\TorrentRepository;
|
||||
use Carbon\Carbon;
|
||||
@@ -42,7 +43,7 @@ class Update extends Install
|
||||
|
||||
public function getLogFile()
|
||||
{
|
||||
return sprintf('%s/nexus-update-%s.log', sys_get_temp_dir(), date('Ymd'));
|
||||
return getLogFile("update");
|
||||
}
|
||||
|
||||
public function getUpdateDirectory()
|
||||
@@ -94,6 +95,7 @@ class Update extends Install
|
||||
public function runExtraQueries()
|
||||
{
|
||||
$toolRep = new ToolRepository();
|
||||
$redis = NExusDB::redis();
|
||||
/**
|
||||
* @since 1.7.13
|
||||
*/
|
||||
@@ -342,9 +344,13 @@ class Update extends Install
|
||||
if (!Schema::hasTable("torrent_extras")) {
|
||||
$this->runMigrate("database/migrations/2025_01_08_133552_create_torrent_extra_table.php");
|
||||
Artisan::call("upgrade:migrate_torrents_table_text_column");
|
||||
Language::updateTransStatus();
|
||||
$this->addSetting('main.complain_enabled', 'yes');
|
||||
}
|
||||
Language::updateTransStatus();
|
||||
$this->addSetting('main.complain_enabled', 'yes');
|
||||
if (!$redis->exists(Setting::USER_TOKEN_PERMISSION_ALLOWED_CACHE_KRY)) {
|
||||
Setting::updateUserTokenPermissionAllowedCache(TokenRepository::listUserTokenPermissions(false));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function runExtraMigrate()
|
||||
|
||||
Reference in New Issue
Block a user