@@ -96,6 +96,10 @@ AccountLinkResultCode GatewayConnectionManager::Link(std::string_view linkCode)
9696
9797 auto response = HTTP::JsonAPI::LinkAccount (linkCode);
9898
99+ if (response.code == 404 ) {
100+ return AccountLinkResultCode::InvalidCode;
101+ }
102+
99103 if (response.result == HTTP ::RequestResult::RateLimited) {
100104 OS_LOGW (TAG , " Account Link request got ratelimited" );
101105 return AccountLinkResultCode::RateLimited;
@@ -106,10 +110,6 @@ AccountLinkResultCode GatewayConnectionManager::Link(std::string_view linkCode)
106110 return AccountLinkResultCode::InternalError;
107111 }
108112
109- if (response.code == 404 ) {
110- return AccountLinkResultCode::InvalidCode;
111- }
112-
113113 if (response.code != 200 ) {
114114 OS_LOGE (TAG , " Unexpected response code: %d" , response.code );
115115 return AccountLinkResultCode::InternalError;
@@ -166,6 +166,12 @@ bool FetchHubInfo(std::string_view authToken)
166166
167167 auto response = HTTP::JsonAPI::GetHubInfo (authToken);
168168
169+ if (response.code == 401 ) {
170+ OS_LOGD (TAG , " Auth token is invalid, clearing it" );
171+ Config::ClearBackendAuthToken ();
172+ return false ;
173+ }
174+
169175 if (response.result == HTTP ::RequestResult::RateLimited) {
170176 return false ; // Just return false, don't spam the console with errors
171177 }
@@ -174,12 +180,6 @@ bool FetchHubInfo(std::string_view authToken)
174180 return false ;
175181 }
176182
177- if (response.code == 401 ) {
178- OS_LOGD (TAG , " Auth token is invalid, clearing it" );
179- Config::ClearBackendAuthToken ();
180- return false ;
181- }
182-
183183 if (response.code != 200 ) {
184184 OS_LOGE (TAG , " Unexpected response code: %d" , response.code );
185185 return false ;
@@ -241,6 +241,12 @@ bool StartConnectingToLCG()
241241
242242 auto response = HTTP::JsonAPI::AssignLcg (authToken);
243243
244+ if (response.code == 401 ) {
245+ OS_LOGD (TAG , " Auth token is invalid, clearing it" );
246+ Config::ClearBackendAuthToken ();
247+ return false ;
248+ }
249+
244250 if (response.result == HTTP ::RequestResult::RateLimited) {
245251 return false ; // Just return false, don't spam the console with errors
246252 }
@@ -249,12 +255,6 @@ bool StartConnectingToLCG()
249255 return false ;
250256 }
251257
252- if (response.code == 401 ) {
253- OS_LOGD (TAG , " Auth token is invalid, clearing it" );
254- Config::ClearBackendAuthToken ();
255- return false ;
256- }
257-
258258 if (response.code != 200 ) {
259259 OS_LOGE (TAG , " Unexpected response code: %d" , response.code );
260260 return false ;
0 commit comments