add createdAt

This commit is contained in:
AJ ONeal 2018-08-05 05:48:17 +00:00
parent c3c4f8893f
commit e4534d6076
1 changed files with 3 additions and 2 deletions

View File

@ -364,11 +364,12 @@ Accounts.link = function (req) {
Accounts.getOrCreate = function (req) { Accounts.getOrCreate = function (req) {
var id = Accounts._getTokenId(req.auth); var id = Accounts._getTokenId(req.auth);
var idNode = { type: 'ppid', name: id }; var idNode = { createdAt: new Date().toISOString(), type: 'ppid', name: id };
return DB.accounts.get(idNode).then(function (acc) { return DB.accounts.get(idNode).then(function (acc) {
if (acc) { return acc; } if (acc) { return acc; }
acc = { id: id, sub: req.auth.sub, iss: req.auth.iss, domains: [], ports: [], nodes: [ idNode ] }; acc = { createdAt: idNode.createdAt, id: id, sub: req.auth.sub, iss: req.auth.iss,
domains: [], ports: [], nodes: [ idNode ] };
return DB.accounts.add(acc).then(function () { return DB.accounts.add(acc).then(function () {
// intentionally not returned to the promise chain // intentionally not returned to the promise chain
DB.save().catch(function (err) { DB.save().catch(function (err) {