include contact nodes in profile

This commit is contained in:
AJ ONeal 2017-12-06 07:05:02 +00:00
parent c152878201
commit efae8caf3b
2 changed files with 13 additions and 4 deletions

View File

@ -496,7 +496,7 @@ function create(deps, app) {
//var contactClaimId = crypto.createHash('sha256').update(account.accountId+':'+params.username_type+':'+params.username).digest('base64'); //var contactClaimId = crypto.createHash('sha256').update(account.accountId+':'+params.username_type+':'+params.username).digest('base64');
return req.Models.IssuerOauth3OrgContactNodes.get(contactClaimId).then(function (contactClaim) { return req.Models.IssuerOauth3OrgContactNodes.get(contactClaimId).then(function (contactClaim) {
var now = Date.now(); 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; } if (!contactClaim.verifiedAt) { contactClaim.verifiedAt = now; }
contactClaim.lastVerifiedAt = now; contactClaim.lastVerifiedAt = now;
@ -543,12 +543,15 @@ function create(deps, app) {
restful.getProfile = function (req, res) { restful.getProfile = function (req, res) {
var promise = req.Models.IssuerOauth3OrgProfiles.get(req.oauth3._IDX_ || req.oauth3.accountIdx).then(function (result) { 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.id = undefined;
//result.prv = 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'); 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'); app.handlePromise(req, res, promise, '[issuer@oauth3.org] set profile');
}; };
restful.listContactNodes = function (req, res) { 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) { restful.claimContact = function (req, res) {
var type = req.body.type; var type = req.body.type;

View File

@ -36,7 +36,7 @@ module.exports = [
tablename: apiname + '_contact_nodes', tablename: apiname + '_contact_nodes',
idname: 'id', idname: 'id',
// contact nodes could apply to either credential or profile? // 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', tablename: apiname + '_jwks',