-
-
Notifications
You must be signed in to change notification settings - Fork 88
sign in via QR code 📸
Yaro Shm edited this page Mar 10, 2024
·
1 revision
You can use gem rqrcode to generate a QR code to login.
Update app/views/passwordless/mailer/sign_in.html.erb
:
<% 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 "false", width is controlled by module_size
standalone: true) %>
<div style="width: 200px;">
<%= raw svg %>
</div>
result:
It is tricker to display the QR code in plain-text email. So far this is the closest I got by updating app/views/passwordless/mailer/sign_in.text.erb
:
<% qrcode = RQRCode::QRCode.new("http://github.com/") %>
<%= qrcode.to_s.gsub('x', "\u2588") %>
🚨 My phone did not manage to read this plain-text QR code. Better solutions would be appreciated