fix error handling
This commit is contained in:
@@ -46,14 +46,22 @@ export default function authorize ( auth, authActions, errActions, configs ) {
|
|||||||
"&scope=" + encodeURIComponent(scopes.join(scopeSeparator))
|
"&scope=" + encodeURIComponent(scopes.join(scopeSeparator))
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
if ( !response.ok ) {
|
||||||
|
errActions.newAuthErr( {
|
||||||
|
authId: name,
|
||||||
|
level: "error",
|
||||||
|
source: "auth",
|
||||||
|
message: response.statusText
|
||||||
|
} )
|
||||||
|
return
|
||||||
|
} else {
|
||||||
response.json()
|
response.json()
|
||||||
.then(function (json){
|
.then(function (json){
|
||||||
authActions.authorizeOauth2({ auth, token: json})
|
authActions.authorizeOauth2({ auth, token: json})
|
||||||
})
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch (function (error) {
|
.catch(err => { errActions.newAuthErr( err ) })
|
||||||
console.log("POST Request failed", error)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
// pass action authorizeOauth2 and authentication data through window
|
// pass action authorizeOauth2 and authentication data through window
|
||||||
// to authorize with oauth2
|
// to authorize with oauth2
|
||||||
|
|||||||
Reference in New Issue
Block a user