mikker / passwordless

🗝 Authentication for your Rails app without the icky-ness of passwords
MIT License
1.25k stars 86 forks source link

sign in via QR code 📸 #210

Closed yshmarov closed 4 months ago

yshmarov commented 4 months ago

I think it could be a great additional feature to enable sign in via QR code using rqrcode.

I managed to add it to my app by adding this code to app/views/passwordless/mailer/sign_in.html.erb:

ruby
<% qrcode = RQRCode::QRCode.new(@magic_link) %>

<% svg = qrcode.as_svg(
  offset: 0,
  color: '000',
  shape_rendering: 'crispEdges',
  module_size: 11,
  viewbox: true, # to control width within div. if not true, width is controlled by module_size
  standalone: true) %>

<div style="width: 200px;">
  <%= raw svg %>
</div>

result:

Screenshot 2024-03-10 at 16 12 06

Although so far I did not find a nice way to display the QR code in plain-text email:

Screenshot 2024-03-10 at 16 16 57
mikker commented 4 months ago

That's nice! I don't think it should go into the stock setup, adding a dependency and all.

I do however love having an example like this around. Let's add it to the docs or perhaps the wiki instead?

yshmarov commented 4 months ago

That's nice! I don't think it should go into the stock setup, adding a dependency and all.

I do however love having an example like this around. Let's add it to the docs or perhaps the wiki instead?

Added to wiki

mikker commented 4 months ago

Wonderful! Thank you again @yshmarov 💙💛