mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: use raster image and autofill in 2FA input (#15429)
- switches to a raster image QR code so it can be long-pressed (or right clicked) and added to iCloud keychain - adds `autocomplete="one-time-code"` to the 2FA input for better discoverability
This commit is contained in:
@@ -1412,16 +1412,14 @@ class UsersController < ApplicationController
|
||||
require 'rotp' if !defined? ROTP
|
||||
totp_data = ROTP::Base32.random
|
||||
secure_session["staged-totp-#{current_user.id}"] = totp_data
|
||||
qrcode_svg = RQRCode::QRCode.new(current_user.totp_provisioning_uri(totp_data)).as_svg(
|
||||
offset: 0,
|
||||
color: '000',
|
||||
shape_rendering: 'crispEdges',
|
||||
module_size: 4
|
||||
qrcode_png = RQRCode::QRCode.new(current_user.totp_provisioning_uri(totp_data)).as_png(
|
||||
border_modules: 1,
|
||||
size: 240
|
||||
)
|
||||
|
||||
render json: success_json.merge(
|
||||
key: totp_data.scan(/.{4}/).join(" "),
|
||||
qr: qrcode_svg
|
||||
qr: qrcode_png.to_data_url
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user