speakeasyjs / speakeasy

**NOT MAINTAINED** Two-factor authentication for Node.js. One-time passcode generator (HOTP/TOTP) with support for Google Authenticator.
MIT License
2.68k stars 229 forks source link

where is the qrcode image actually saved? #103

Closed zhaofeihao closed 6 years ago

zhaofeihao commented 6 years ago

where is the qrcode image actually saved after generated

markbao commented 6 years ago

This package doesn't natively include code to display a QR code. If you're using the example code from the README, it doesn't store the QR code anywhere, instead it converts the QR code into a string which represents the image (a data URL) which you can put inside an tag.

zhaofeihao commented 6 years ago

@markbao so it means every time generate a new qrcode image? how i can generate the same qrcode for a specfic user with his username and password

markbao commented 6 years ago

Can you explain to me your setup? Generally you would want to generate a key for a user, and then save that key to the user's account, and then show the QR code based on that key to allow the user add the key to their phone app. Generally you don't show the QR code again.

zhaofeihao commented 6 years ago

@markbao ohhh,I see your point! thanks very very very much! btw

 
var segs = [
    { data: username, mode: 'alphanumeric' },
    { data: password, mode: 'numeric' }
  ]

  QRCode.toDataURL(segs, function (err, url) {
    console.log(url)
  })

can i config like this to generate a qrcode for each user,so that it is unique?

markbao commented 6 years ago

I don't think this is the right way to do it - this looks like you're creating a QR code from the user's username and password, not their key. You first need to generate a key for the user - the user's username and password are not supposed to be their key. Next, you need to put the key in the QR code, and there is a specific string format that the key should be in (an otpauth URL). Do not create a QR code from the user's username/password - it won't work. I suggest looking for a tutorial on using this package to guide the implementation.

zhaofeihao commented 6 years ago

@markbao thx~