Only consider most recent user self certification

This commit is contained in:
Daniel Huigens 2018-04-18 14:15:34 +02:00
parent 122d526f49
commit 39c7374d70

View File

@ -528,8 +528,7 @@ Key.prototype.getValidUsers = async function(date=new Date(), allowExpired=false
return; return;
} }
const dataToVerify = { userid: user.userId , key: primaryKey }; const dataToVerify = { userid: user.userId , key: primaryKey };
for (let j = 0; j < user.selfCertifications.length; j++) { const cert = getLatestSignature(user.selfCertifications);
const cert = user.selfCertifications[j];
// skip if certificate is not the most recent // skip if certificate is not the most recent
if ((cert.isPrimaryUserID && cert.isPrimaryUserID < lastPrimaryUserID) || if ((cert.isPrimaryUserID && cert.isPrimaryUserID < lastPrimaryUserID) ||
(!lastPrimaryUserID && cert.created < lastCreated)) { (!lastPrimaryUserID && cert.created < lastCreated)) {
@ -551,7 +550,6 @@ Key.prototype.getValidUsers = async function(date=new Date(), allowExpired=false
lastCreated = cert.created; lastCreated = cert.created;
validUsers.push({ index: i, user: user, selfCertification: cert }); validUsers.push({ index: i, user: user, selfCertification: cert });
} }
}
return validUsers; return validUsers;
}; };