Use controller for setting up QR Code

This commit is contained in:
Dominik Kwiatek 2020-10-19 14:56:13 +02:00
parent 00da21a13d
commit 433f1d45e5
2 changed files with 5 additions and 6 deletions

View File

@ -177,10 +177,9 @@ class UserController < ApplicationController
current_user.otp_secret_key = User.otp_random_secret
@provisioning_uri = current_user.provisioning_uri(nil, issuer: APP_CONFIG[:hostname])
qr_code = RQRCode::QRCode.new(@provisioning_uri, :size => 12, :level => :h)
@qr_svg = qr_code.as_svg(offset: 0, color: '000',
shape_rendering: 'crispEdges',
module_size: 4)
qr_code = RQRCode::QRCode.new(current_user.provisioning_uri("Retrospring:#{current_user.screen_name}", issuer: "Retrospring"))
@qr_svg = qr_code.as_svg({offset: 4, module_size: 4, color: '000;fill:var(--primary)'}).html_safe
end
def update_2fa

View File

@ -6,7 +6,7 @@
.totp-setup__left
.totp-setup__card
.totp-setup__qr
= RQRCode::QRCode.new(current_user.provisioning_uri("Retrospring:#{current_user.screen_name}", issuer: "Retrospring")).as_svg({:offset => 4, :module_size => 4, :color => '000;fill:var(--primary)'}).html_safe
= @qr_svg
%p.totp-setup__text
If you cannot scan the QR code, use the following key instead:
%code= current_user.otp_secret_key.scan(/.{4}/).flatten.join(' ')
@ -29,4 +29,4 @@
= f.submit t('views.actions.save'), class: 'btn btn-primary'
- else
%p Your account is set up to require the use of a one-time password in order to log in
= link_to t('views.actions.remove'), destroy_user_2fa_path, :class => 'btn btn-primary', :method => 'delete', :data => { confirm: "Are you sure you want to disable two-factor authentication?" }
= link_to t('views.actions.remove'), destroy_user_2fa_path, class: 'btn btn-primary', method: 'delete', data: { confirm: "Are you sure you want to disable two-factor authentication?" }