correct order of operations

This commit is contained in:
AJ ONeal 2018-06-29 12:06:34 +00:00
parent a3b8cd6799
commit 5b90d5ef38
1 changed files with 32 additions and 20 deletions

View File

@ -257,9 +257,18 @@ var Server = {
newAuth = JSON.stringify(newAuth);
}
// TODO don't fire the onAuth event on non-authz updates
if (!grant.jwt && !(grant.domains||[]).length && !(grant.ports||[]).length) {
return null;
}
console.log('[onAuth] check for upgrade token');
if (grant.jwt && newAuth !== grant.jwt) {
console.log('new token to send back');
if (grant.jwt) {
if (newAuth !== grant.jwt) {
console.log('[onAuth] new token to send back');
}
// TODO only send token when new
if (true) {
// Access Token
Server.sendTunnelMsg(
srv
@ -273,6 +282,7 @@ var Server = {
// these aren't needed internally once they're sent
grant.jwt = null;
}
}
/*
if (!Array.isArray(grant.domains) || !grant.domains.length) {
@ -425,22 +435,24 @@ var Server = {
}
return state.authenticate({ auth: newAuth }).then(function (authnToken) {
console.log('\n[relay.js] newAuth');
console.log(newAuth);
console.log('\n[relay.js] authnToken');
console.log(authnToken);
if (authnToken.id) {
state.srvs[authnToken.id] = state.srvs[authnToken.id] || {};
// For tracking state between token exchanges
// and tacking on extra attributes (i.e. for extensions)
// TODO close on delete
if (!state.srvs[authnToken.id]) {
state.srvs[authnToken.id] = {};
}
if (!state.srvs[authnToken.id].updateAuth) {
state.srvs[authnToken.id].updateAuth = function (validToken) {
return Server.onAuth(state, srv, newAuth, validToken);
};
}
// will return rejection if necessary
return state.srvs[authnToken.id].updateAuth(authnToken);
state.srvs[authnToken.id].updateAuth(authnToken);
});
}
, removeToken: function removeToken(state, srv, jwtoken) {