mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-27 08:19:30 +08:00
WebAPI: return correct status
Fix web API returning Not Found instead of Forbidden. When not having a session the API would return "Not Found" instead of "Forbidden" when trying to access a non-public endpoint. PR #16866.
This commit is contained in:
parent
a2b85ba1fd
commit
669b67e666
@ -252,6 +252,9 @@ void WebApplication::doProcessRequest()
|
|||||||
const QString action = match.captured(u"action"_qs);
|
const QString action = match.captured(u"action"_qs);
|
||||||
const QString scope = match.captured(u"scope"_qs);
|
const QString scope = match.captured(u"scope"_qs);
|
||||||
|
|
||||||
|
if (!session() && !isPublicAPI(scope, action))
|
||||||
|
throw ForbiddenHTTPError();
|
||||||
|
|
||||||
APIController *controller = nullptr;
|
APIController *controller = nullptr;
|
||||||
if (session())
|
if (session())
|
||||||
controller = session()->getAPIController(scope);
|
controller = session()->getAPIController(scope);
|
||||||
@ -263,9 +266,6 @@ void WebApplication::doProcessRequest()
|
|||||||
throw NotFoundHTTPError();
|
throw NotFoundHTTPError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!session() && !isPublicAPI(scope, action))
|
|
||||||
throw ForbiddenHTTPError();
|
|
||||||
|
|
||||||
DataMap data;
|
DataMap data;
|
||||||
for (const Http::UploadedFile &torrent : request().files)
|
for (const Http::UploadedFile &torrent : request().files)
|
||||||
data[torrent.filename] = torrent.data;
|
data[torrent.filename] = torrent.data;
|
||||||
|
Loading…
Reference in New Issue
Block a user