mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
JSON API spit out CORS headers also on error
Browsers won't let JavaScript properly handle the error if the corsa headers are missing thanks Saud for report see: retroshare://forum?name=Shouldn%27t%20CORS%20headers%20be%20present%20for%20all%20API%20responses%3F&id=8fd22bd8f99754461e7ba1ca8a727995&msgid=e3232ae3a1b76698576a9159ba962fa5091e710c
This commit is contained in:
parent
1666ce290a
commit
92990c55e7
@ -417,7 +417,7 @@ void JsonApiServer::registerHandler(
|
||||
|
||||
if(!rsLoginHelper->isLoggedIn())
|
||||
{
|
||||
session->close(rb::CONFLICT);
|
||||
session->close(rb::CONFLICT, corsOptionsHeaders);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -429,7 +429,7 @@ void JsonApiServer::registerHandler(
|
||||
|
||||
if(authToken != "Basic")
|
||||
{
|
||||
session->close(rb::UNAUTHORIZED);
|
||||
session->close(rb::UNAUTHORIZED, corsOptionsHeaders);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -437,7 +437,7 @@ void JsonApiServer::registerHandler(
|
||||
authToken = decodeToken(authToken);
|
||||
|
||||
if(isAuthTokenValid(authToken)) callback(session);
|
||||
else session->close(rb::UNAUTHORIZED);
|
||||
else session->close(rb::UNAUTHORIZED, corsOptionsHeaders);
|
||||
} );
|
||||
|
||||
mResources.push_back(resource);
|
||||
|
Loading…
Reference in New Issue
Block a user