diff --git a/meshuser.js b/meshuser.js index 95530a3d..cee03759 100644 --- a/meshuser.js +++ b/meshuser.js @@ -2213,7 +2213,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use parent.f2l.attestationResult(clientAttestationResponse, attestationExpectations).then(function (regResult) { // Since we are registering a WebAuthn/FIDO2 key, remove all U2F keys (Type 1). var otphkeys2 = []; - for (var i = 0; i < user.otphkeys.length; i++) { if (user.otphkeys[i].type != 1) { otphkeys2.push(user.otphkeys[i]); } } + if (user.otphkeys && Array.isArray(user.otphkeys)) { for (var i = 0; i < user.otphkeys.length; i++) { if (user.otphkeys[i].type != 1) { otphkeys2.push(user.otphkeys[i]); } } } user.otphkeys = otphkeys2; // Add the new WebAuthn/FIDO2 keys