forked from gCubeSystem/conductor-setup
added more info on token parse error
This commit is contained in:
parent
66a86dfe1a
commit
571a988be9
|
@ -129,7 +129,12 @@ function verifyToken(context){
|
|||
return context.request.subrequest("/jwt_verify_request", options)
|
||||
.then(reply=>{
|
||||
if (reply.status === 200) {
|
||||
var response = JSON.parse(reply.responseBody);
|
||||
var response = null
|
||||
try{
|
||||
response = JSON.parse(reply.responseBody);
|
||||
} catch(error){
|
||||
throw new Error("Unable to parse response json from token request: " + reply.responseBody)
|
||||
}
|
||||
if (response.active === true) {
|
||||
return response
|
||||
} else {
|
||||
|
@ -153,7 +158,12 @@ function requestToken(context){
|
|||
return context.request.subrequest("/jwt_request", options)
|
||||
.then(reply=>{
|
||||
if (reply.status === 200) {
|
||||
var response = JSON.parse(reply.responseBody);
|
||||
var response = null
|
||||
try{
|
||||
response = JSON.parse(reply.responseBody);
|
||||
} catch(error){
|
||||
throw new Error("Unable to parse response json from token request: " + reply.responseBody)
|
||||
}
|
||||
context.authn.token = response.access_token
|
||||
context.authn.verified_token =
|
||||
JSON.parse(Buffer.from(context.authn.token.split('.')[1], 'base64url').toString())
|
||||
|
|
Loading…
Reference in New Issue