Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
ThaliApp
Commits
22b16bfa
Verified
Commit
22b16bfa
authored
Aug 29, 2018
by
Sébastiaan Versteeg
Browse files
Fix detectInvalidToken in case of empty response
parent
cfee4808
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/utils/url.js
View file @
22b16bfa
...
...
@@ -32,16 +32,19 @@ export class TokenInvalidError extends Error {
const
detectInvalidToken
=
(
response
)
=>
{
const
responseCopy
=
response
.
clone
();
return
response
.
json
().
then
((
json
)
=>
{
if
(
response
.
status
===
403
)
{
const
contentLang
=
response
.
headers
.
get
(
'
content-language
'
);
if
((
contentLang
===
'
en
'
&&
json
.
detail
===
'
Invalid token.
'
)
||
(
contentLang
===
'
nl
'
&&
json
.
detail
===
'
Ongeldige token.
'
))
{
throw
new
TokenInvalidError
(
responseCopy
);
if
(
response
.
status
===
403
)
{
return
response
.
json
().
then
((
json
)
=>
{
if
(
response
.
status
===
403
)
{
const
contentLang
=
response
.
headers
.
get
(
'
content-language
'
);
if
((
contentLang
===
'
en
'
&&
json
.
detail
===
'
Invalid token.
'
)
||
(
contentLang
===
'
nl
'
&&
json
.
detail
===
'
Ongeldige token.
'
))
{
throw
new
TokenInvalidError
(
responseCopy
);
}
}
}
return
responseCopy
;
});
return
responseCopy
;
});
}
return
Promise
.
resolve
(
responseCopy
);
};
export
const
apiRequest
=
(
route
,
fetchOpts
,
params
)
=>
{
...
...
Sébastiaan Versteeg
@sversteeg
mentioned in merge request
!211 (merged)
·
Oct 10, 2018
mentioned in merge request
!211 (merged)
mentioned in merge request !211
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment