Use controller for setting up QR Code
This commit is contained in:
parent
00da21a13d
commit
433f1d45e5
|
@ -177,10 +177,9 @@ class UserController < ApplicationController
|
||||||
current_user.otp_secret_key = User.otp_random_secret
|
current_user.otp_secret_key = User.otp_random_secret
|
||||||
|
|
||||||
@provisioning_uri = current_user.provisioning_uri(nil, issuer: APP_CONFIG[:hostname])
|
@provisioning_uri = current_user.provisioning_uri(nil, issuer: APP_CONFIG[:hostname])
|
||||||
qr_code = RQRCode::QRCode.new(@provisioning_uri, :size => 12, :level => :h)
|
qr_code = RQRCode::QRCode.new(current_user.provisioning_uri("Retrospring:#{current_user.screen_name}", issuer: "Retrospring"))
|
||||||
@qr_svg = qr_code.as_svg(offset: 0, color: '000',
|
|
||||||
shape_rendering: 'crispEdges',
|
@qr_svg = qr_code.as_svg({offset: 4, module_size: 4, color: '000;fill:var(--primary)'}).html_safe
|
||||||
module_size: 4)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_2fa
|
def update_2fa
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
.totp-setup__left
|
.totp-setup__left
|
||||||
.totp-setup__card
|
.totp-setup__card
|
||||||
.totp-setup__qr
|
.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
|
%p.totp-setup__text
|
||||||
If you cannot scan the QR code, use the following key instead:
|
If you cannot scan the QR code, use the following key instead:
|
||||||
%code= current_user.otp_secret_key.scan(/.{4}/).flatten.join(' ')
|
%code= current_user.otp_secret_key.scan(/.{4}/).flatten.join(' ')
|
||||||
|
@ -29,4 +29,4 @@
|
||||||
= f.submit t('views.actions.save'), class: 'btn btn-primary'
|
= f.submit t('views.actions.save'), class: 'btn btn-primary'
|
||||||
- else
|
- else
|
||||||
%p Your account is set up to require the use of a one-time password in order to log in
|
%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?" }
|
Loading…
Reference in New Issue