mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-21 09:20:08 -05:00
refactor: use enums for auth guards, middleware groups, and rate limits
This commit is contained in:
@@ -17,6 +17,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\DTO\TorrentSearchFiltersDTO;
|
||||
use App\Enums\AuthGuard;
|
||||
use App\Helpers\Bencode;
|
||||
use App\Helpers\TorrentHelper;
|
||||
use App\Helpers\TorrentTools;
|
||||
@@ -487,7 +488,7 @@ class TorrentController extends BaseController
|
||||
TorrentHelper::approveHelper($torrent->id);
|
||||
}
|
||||
|
||||
return $this->sendResponse(route('torrent.download.rsskey', ['id' => $torrent->id, 'rsskey' => auth('api')->user()->rsskey]), 'Torrent uploaded successfully.');
|
||||
return $this->sendResponse(route('torrent.download.rsskey', ['id' => $torrent->id, 'rsskey' => auth(AuthGuard::API->value)->user()->rsskey]), 'Torrent uploaded successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -714,8 +715,8 @@ class TorrentController extends BaseController
|
||||
|
||||
// Auth keys must not be cached
|
||||
$torrents->through(function ($torrent) {
|
||||
$torrent['attributes']['download_link'] = route('torrent.download.rsskey', ['id' => $torrent['id'], 'rsskey' => auth('api')->user()->rsskey]);
|
||||
$torrent['attributes']['magnet_link'] = config('torrent.magnet') ? 'magnet:?dn='.$torrent['attributes']['name'].'&xt=urn:btih:'.$torrent['attributes']['info_hash'].'&as='.route('torrent.download.rsskey', ['id' => $torrent['id'], 'rsskey' => auth('api')->user()->rsskey]).'&tr='.route('announce', ['passkey' => auth('api')->user()->passkey]).'&xl='.$torrent['attributes']['size'] : null;
|
||||
$torrent['attributes']['download_link'] = route('torrent.download.rsskey', ['id' => $torrent['id'], 'rsskey' => auth(AuthGuard::API->value)->user()->rsskey]);
|
||||
$torrent['attributes']['magnet_link'] = config('torrent.magnet') ? 'magnet:?dn='.$torrent['attributes']['name'].'&xt=urn:btih:'.$torrent['attributes']['info_hash'].'&as='.route('torrent.download.rsskey', ['id' => $torrent['id'], 'rsskey' => auth(AuthGuard::API->value)->user()->rsskey]).'&tr='.route('announce', ['passkey' => auth('api')->user()->passkey]).'&xl='.$torrent['attributes']['size'] : null;
|
||||
|
||||
return $torrent;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user