NodeBB / nodebb-plugin-2factor

Two-Factor Authentication for NodeBB
MIT License
12 stars 15 forks source link

Crash on 2fa login to admin panel #79

Closed nebulade closed 2 years ago

nebulade commented 2 years ago

After the latest upgrade of nodebb to v2.4.4 the 2fa login (v5.0.2) crashes with the following error:

Aug 19 15:47:18 TypeError: Cannot set properties of undefined (setting 'datetime')
Aug 19 15:47:18 at /run/nodebb/node_modules/nodebb-plugin-2factor/library.js:47:29
Aug 19 15:47:18 at Layer.handle [as handle_request] (/run/nodebb/node_modules/express/lib/router/layer.js:95:5)
Aug 19 15:47:18 at next (/run/nodebb/node_modules/express/lib/router/route.js:144:13)
Aug 19 15:47:18 at complete (/run/nodebb/node_modules/passport/lib/middleware/authenticate.js:271:13)
Aug 19 15:47:18 at /run/nodebb/node_modules/passport/lib/middleware/authenticate.js:278:15
Aug 19 15:47:18 at pass (/run/nodebb/node_modules/passport/lib/authenticator.js:428:14)
Aug 19 15:47:18 at Authenticator.transformAuthInfo (/run/nodebb/node_modules/passport/lib/authenticator.js:450:5)
Aug 19 15:47:18 at /run/nodebb/node_modules/passport/lib/middleware/authenticate.js:275:22
Aug 19 15:47:18 at /run/nodebb/node_modules/passport/lib/http/request.js:41:7
Aug 19 15:47:18 at /run/nodebb/node_modules/passport/lib/sessionmanager.js:51:9

Basically req.session.meta is undefined at that point.

julianlam commented 2 years ago

Thanks! Resolved as of nodebb/nodebb@9b96c33d5d3706f9c5795b9c07ace063f69b101d

nebulade commented 2 years ago

This was fast! The fix looks a lot more involved than I thought, would have taken me a long time as I was clearly investigating in the wrong corners myself :)

julianlam commented 2 years ago

Sorry about that, it seems like the upstream update to passport 0.6 was a breaking change, so we needed to make it... Not-so-breaking 🙂