Harden community profile identity rendering
This commit is contained in:
+6
-1
@@ -31,11 +31,12 @@
|
||||
if (response.status === 401 && window.CrankAuth && typeof window.CrankAuth.handleUnauthorized === 'function') {
|
||||
window.CrankAuth.handleUnauthorized();
|
||||
}
|
||||
var looksLikeHtml = /^\s*</.test(text || '');
|
||||
var message = payload && payload.error
|
||||
? payload.error.message
|
||||
: payload && payload.message
|
||||
? payload.message
|
||||
: text
|
||||
: text && !looksLikeHtml
|
||||
? text
|
||||
: ('HTTP ' + response.status);
|
||||
var error = new Error(message);
|
||||
@@ -44,6 +45,10 @@
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (text && payload === null) {
|
||||
throw new Error('Backend returned a non-JSON response');
|
||||
}
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user