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