From efae8caf3b0296a69ef3191f37444f4e4f201301 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 6 Dec 2017 07:05:02 +0000 Subject: [PATCH] include contact nodes in profile --- accounts.js | 15 ++++++++++++--- models.js | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/accounts.js b/accounts.js index 832aa0a..4aa653c 100644 --- a/accounts.js +++ b/accounts.js @@ -496,7 +496,7 @@ function create(deps, app) { //var contactClaimId = crypto.createHash('sha256').update(account.accountId+':'+params.username_type+':'+params.username).digest('base64'); return req.Models.IssuerOauth3OrgContactNodes.get(contactClaimId).then(function (contactClaim) { var now = Date.now(); - if (!contactClaim) { contactClaim = { id: contactClaimId }; } + if (!contactClaim) { contactClaim = { id: contactClaimId, accountId: (req.oauth3._IDX_ || req.oauth3.accountIdx) }; } if (!contactClaim.verifiedAt) { contactClaim.verifiedAt = now; } contactClaim.lastVerifiedAt = now; @@ -543,12 +543,15 @@ function create(deps, app) { restful.getProfile = function (req, res) { var promise = req.Models.IssuerOauth3OrgProfiles.get(req.oauth3._IDX_ || req.oauth3.accountIdx).then(function (result) { - if (!result) { result = { id: undefined }; } + if (!result) { return { id: undefined }; } result.id = undefined; //result.prv = undefined; - return result; + return req.Models.IssuerOauth3OrgContactNodes.find({ accountId: req.oauth3.accountIdx }).then(function (nodes) { + result.nodes = nodes; + return result; + }); }); app.handlePromise(req, res, promise, '[issuer@oauth3.org] get profile'); @@ -599,6 +602,12 @@ function create(deps, app) { app.handlePromise(req, res, promise, '[issuer@oauth3.org] set profile'); }; restful.listContactNodes = function (req, res) { + /* + var contactClaimId = crypto.createHash('sha256').update((req.oauth3._IDX_ || req.oauth3.accountIdx)+':'+code.node.type+':'+code.node.node).digest('base64'); + return req.Models.IssuerOauth3OrgContactNodes.get(contactClaimId).then(function (contactClaim) { + return; + }); + */ }; restful.claimContact = function (req, res) { var type = req.body.type; diff --git a/models.js b/models.js index 29a9bdd..c4afb6e 100644 --- a/models.js +++ b/models.js @@ -36,7 +36,7 @@ module.exports = [ tablename: apiname + '_contact_nodes', idname: 'id', // contact nodes could apply to either credential or profile? - indices: baseFields.concat([ 'accountId', 'verifiedAt', 'lastVerifiedAt' ]), + indices: baseFields.concat([ 'accountId', 'priority', 'verifiedAt', 'lastVerifiedAt' ]), }, { tablename: apiname + '_jwks',