Fixed WebAuth key addition

Ylian Saint-Hilaire committed Apr 22, 2019 at 16:37 UTC 1204fb93c24737548aded9bc2caccc5f56fb6523
1 file changed +1 -1
meshuser.js
+1 -1
@@ -2213,7 +2213,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2213 parent.f2l.attestationResult(clientAttestationResponse, attestationExpectations).then(function (regResult) {
2214 // Since we are registering a WebAuthn/FIDO2 key, remove all U2F keys (Type 1).
2215 var otphkeys2 = [];
2216 - for (var i = 0; i < user.otphkeys.length; i++) { if (user.otphkeys[i].type != 1) { otphkeys2.push(user.otphkeys[i]); } }
2216 + 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]); } } }
2217 user.otphkeys = otphkeys2;
2218
2219 // Add the new WebAuthn/FIDO2 keys