speakeasyjs/speakeasy

where is the qrcode image actually saved?

zhaofeihao opened this issue · 6 comments

where is the qrcode image actually saved after generated

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.

@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

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.

@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?

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.