-
Notifications
You must be signed in to change notification settings - Fork 0
Qr #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qr #65
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -970,9 +970,14 @@ exports.getTotpSetup = async (req, res, next) => { | |
| secret, | ||
| }); | ||
| req.session.totpSecret = secret.base32; | ||
| // Generate QR image (SVG) data URI using the `qr` package | ||
| const qrModule = await import('qr'); | ||
| const encodeQR = qrModule.default || qrModule; | ||
| const svg = encodeQR(totp.toString(), 'svg'); | ||
| const qrImage = `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`; | ||
| res.render('account/totp-setup', { | ||
| title: 'Setup Authenticator', | ||
| qrCode: totp.toString(), | ||
| qrImage, | ||
|
Comment on lines
+973
to
+980
|
||
| secret: secret.base32, | ||
| }); | ||
| } catch (err) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await import('qr')is executed inside the request handler. Even though Node caches modules, doing this per request adds async overhead and can surface runtime import failures only when this route is hit. Prefer importing once at module scope (or memoizing the import) so failures happen at startup and the handler stays synchronous aside from DB work.