bugfixes
This commit is contained in:
parent
a2b23b2509
commit
4f2948d0f0
|
@ -188,13 +188,13 @@ DB.ports._add = function (acc, number) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
DB._save = function () {
|
DB._save = function () {
|
||||||
return sfs.writeAsync('./accounts.json', JSON.stringify(DB._perms));
|
return sfs.writeFileAsync('./accounts.json', JSON.stringify(DB._perms));
|
||||||
};
|
};
|
||||||
DB._saveToken = null;
|
DB._saveToken = null;
|
||||||
DB._savePromises = [];
|
DB._savePromises = [];
|
||||||
DB._savePromise = PromiseA.resolve();
|
DB._savePromise = PromiseA.resolve();
|
||||||
DB.save = function () {
|
DB.save = function () {
|
||||||
cancelTimeout(DB._saveToken);
|
clearTimeout(DB._saveToken);
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
function doSave() {
|
function doSave() {
|
||||||
DB._savePromise = DB._savePromise.then(function () {
|
DB._savePromise = DB._savePromise.then(function () {
|
||||||
|
@ -214,7 +214,7 @@ DB.save = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
DB._saveToken = setTimeout(doSave, 2500);
|
DB._saveToken = setTimeout(doSave, 2500);
|
||||||
DB.savePromises.push({ resolve: resolve, reject: reject });
|
DB._savePromises.push({ resolve: resolve, reject: reject });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -917,7 +917,7 @@ Accounts._associateEmails = function (req) {
|
||||||
// oauth3.org, issuer@oauth3.org, profile
|
// oauth3.org, issuer@oauth3.org, profile
|
||||||
return OAUTH3.request({
|
return OAUTH3.request({
|
||||||
url: "https://api." + req.auth.data.iss + "/api/issuer@oauth3.org/acl/profile"
|
url: "https://api." + req.auth.data.iss + "/api/issuer@oauth3.org/acl/profile"
|
||||||
, session: { accessToken: req.auth.jwt }
|
, session: { accessToken: req.auth.jwt, token: req.auth.data }
|
||||||
}).then(function (resp) {
|
}).then(function (resp) {
|
||||||
var email;
|
var email;
|
||||||
var err;
|
var err;
|
||||||
|
@ -940,7 +940,7 @@ Accounts._associateEmails = function (req) {
|
||||||
};
|
};
|
||||||
app.get('/api/telebit.cloud/account', function (req, res) {
|
app.get('/api/telebit.cloud/account', function (req, res) {
|
||||||
return Accounts.getOrCreate(req).then(function (acc) {
|
return Accounts.getOrCreate(req).then(function (acc) {
|
||||||
var hasEmail = subData.nodes.some(function (node) {
|
var hasEmail = acc.nodes.some(function (node) {
|
||||||
return 'email' === node.type;
|
return 'email' === node.type;
|
||||||
});
|
});
|
||||||
function getAllGrants() {
|
function getAllGrants() {
|
||||||
|
@ -953,6 +953,8 @@ app.get('/api/telebit.cloud/account', function (req, res) {
|
||||||
result.domains.length = 0;
|
result.domains.length = 0;
|
||||||
result.ports.length = 0;
|
result.ports.length = 0;
|
||||||
grants.forEach(function (account) {
|
grants.forEach(function (account) {
|
||||||
|
if (!account) { return; }
|
||||||
|
console.log('grants.forEach.account: ', account);
|
||||||
account.domains.forEach(function (d) {
|
account.domains.forEach(function (d) {
|
||||||
domainsMap[d.name] = d;
|
domainsMap[d.name] = d;
|
||||||
});
|
});
|
||||||
|
@ -986,6 +988,7 @@ app.get('/api/telebit.cloud/account', function (req, res) {
|
||||||
error: {
|
error: {
|
||||||
code: err.code || "E_GENERIC"
|
code: err.code || "E_GENERIC"
|
||||||
, message: err.toString()
|
, message: err.toString()
|
||||||
|
, _stack: err.stack
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue