Only consider most recent user self certification
This commit is contained in:
parent
122d526f49
commit
39c7374d70
42
src/key.js
42
src/key.js
|
@ -528,29 +528,27 @@ 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)) {
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// skip if certificates is invalid, revoked, or expired
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
|
||||||
if (!(cert.verified || await cert.verify(primaryKey, dataToVerify))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
|
||||||
if (cert.revoked || await user.isRevoked(primaryKey, cert, null, date)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!allowExpired && cert.isExpired(date)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
lastPrimaryUserID = cert.isPrimaryUserID;
|
|
||||||
lastCreated = cert.created;
|
|
||||||
validUsers.push({ index: i, user: user, selfCertification: cert });
|
|
||||||
}
|
}
|
||||||
|
// skip if certificates is invalid, revoked, or expired
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
if (!(cert.verified || await cert.verify(primaryKey, dataToVerify))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
if (cert.revoked || await user.isRevoked(primaryKey, cert, null, date)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!allowExpired && cert.isExpired(date)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
lastPrimaryUserID = cert.isPrimaryUserID;
|
||||||
|
lastCreated = cert.created;
|
||||||
|
validUsers.push({ index: i, user: user, selfCertification: cert });
|
||||||
}
|
}
|
||||||
return validUsers;
|
return validUsers;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user