name more clearly

This commit is contained in:
AJ ONeal 2018-06-29 20:05:59 +00:00
parent 5b90d5ef38
commit 6b6ffd4647
1 changed files with 16 additions and 14 deletions

View File

@ -259,10 +259,12 @@ var Server = {
// TODO don't fire the onAuth event on non-authz updates // TODO don't fire the onAuth event on non-authz updates
if (!grant.jwt && !(grant.domains||[]).length && !(grant.ports||[]).length) { if (!grant.jwt && !(grant.domains||[]).length && !(grant.ports||[]).length) {
console.log("[onAuth] nothing to offer at all");
return null; return null;
} }
console.log('[onAuth] check for upgrade token'); console.log('[onAuth] check for upgrade token');
console.log(grant);
if (grant.jwt) { if (grant.jwt) {
if (newAuth !== grant.jwt) { if (newAuth !== grant.jwt) {
console.log('[onAuth] new token to send back'); console.log('[onAuth] new token to send back');
@ -275,7 +277,7 @@ var Server = {
, null , null
, [ 3 , [ 3
, 'access_token' , 'access_token'
, { jwt: grant.jwt } , { jwt: grant.jwt || grant.access_token }
] ]
, 'control' , 'control'
); );
@ -426,33 +428,33 @@ var Server = {
process.nextTick(function () { conn.resume(); }); process.nextTick(function () { conn.resume(); });
}); });
} }
, addToken: function addToken(state, srv, newAuth) { , addToken: function addToken(state, srv, rawAuth) {
console.log("[addToken]", newAuth); console.log("[addToken]", rawAuth);
if (srv.grants[newAuth]) { if (srv.grants[rawAuth]) {
console.log("addToken - duplicate"); console.log("addToken - duplicate");
// return { message: "token sent multiple times", code: "E_TOKEN_REPEAT" }; // return { message: "token sent multiple times", code: "E_TOKEN_REPEAT" };
return state.Promise.resolve(null); return state.Promise.resolve(null);
} }
return state.authenticate({ auth: newAuth }).then(function (authnToken) { return state.authenticate({ auth: rawAuth }).then(function (validatedTokenData) {
console.log('\n[relay.js] newAuth'); console.log('\n[relay.js] rawAuth');
console.log(newAuth); console.log(rawAuth);
console.log('\n[relay.js] authnToken'); console.log('\n[relay.js] authnToken');
console.log(authnToken); console.log(validatedTokenData);
// For tracking state between token exchanges // For tracking state between token exchanges
// and tacking on extra attributes (i.e. for extensions) // and tacking on extra attributes (i.e. for extensions)
// TODO close on delete // TODO close on delete
if (!state.srvs[authnToken.id]) { if (!state.srvs[validatedTokenData.id]) {
state.srvs[authnToken.id] = {}; state.srvs[validatedTokenData.id] = {};
} }
if (!state.srvs[authnToken.id].updateAuth) { if (!state.srvs[validatedTokenData.id].updateAuth) {
state.srvs[authnToken.id].updateAuth = function (validToken) { state.srvs[validatedTokenData.id].updateAuth = function (validatedTokenData) {
return Server.onAuth(state, srv, newAuth, validToken); return Server.onAuth(state, srv, rawAuth, validatedTokenData);
}; };
} }
state.srvs[authnToken.id].updateAuth(authnToken); state.srvs[validatedTokenData.id].updateAuth(validatedTokenData);
}); });
} }
, removeToken: function removeToken(state, srv, jwtoken) { , removeToken: function removeToken(state, srv, jwtoken) {