mirror of https://github.com/docusealco/docuseal
parent
a87ca65839
commit
489f9859be
@ -0,0 +1,20 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class MfaForceController < ApplicationController
|
||||||
|
before_action :load_account_config
|
||||||
|
authorize_resource :account_config
|
||||||
|
|
||||||
|
def create
|
||||||
|
@account_config.update!(value: !@account_config.value)
|
||||||
|
|
||||||
|
redirect_back fallback_location: settings_users_path,
|
||||||
|
notice: "Force 2FA has been #{@account_config.value ? 'enabled' : 'disabled'}."
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def load_account_config
|
||||||
|
@account_config =
|
||||||
|
AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::FORCE_MFA)
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
<%= form_for '', url: mfa_setup_path, data: { turbo_frame: :_top }, html: { id: 'mfa_form'} do |f| %>
|
||||||
|
<p class="text-center">
|
||||||
|
Use an authenticator mobile app like Google Authenticator or 1Password to scan the QR code below.
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<%== RQRCode::QRCode.new(@provision_url).as_svg(viewbox: true, svg_attributes: { class: 'w-80 h-80 my-4 mx-auto' }) %>
|
||||||
|
</div>
|
||||||
|
<div class="form-control my-6 space-y-2">
|
||||||
|
<%= f.text_field :otp_attempt, required: true, placeholder: 'XXX-XXX', class: 'base-input text-center' %>
|
||||||
|
<span>
|
||||||
|
<%= @error_message %>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="form-control mt-4">
|
||||||
|
<%= f.button button_title(title: 'Save'), class: 'base-button' %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
@ -1,19 +1,3 @@
|
|||||||
<%= render 'shared/turbo_modal', title: 'Setup 2FA' do %>
|
<%= render 'shared/turbo_modal', title: 'Setup 2FA' do %>
|
||||||
<%= form_for '', url: mfa_setup_path, data: { turbo_frame: :_top } do |f| %>
|
<%= render 'mfa_setup/form' %>
|
||||||
<p class="text-center">
|
|
||||||
Use an authenticator mobile app like Google Authenticator or 1Password to scan the QR code below.
|
|
||||||
</p>
|
|
||||||
<div>
|
|
||||||
<%== RQRCode::QRCode.new(@provision_url).as_svg(viewbox: true, svg_attributes: { class: 'w-80 h-80 my-4 mx-auto' }) %>
|
|
||||||
</div>
|
|
||||||
<div class="form-control my-6 space-y-2">
|
|
||||||
<%= f.text_field :otp_attempt, required: true, placeholder: 'XXX-XXX', class: 'base-input text-center' %>
|
|
||||||
<span>
|
|
||||||
<%= @error_message %>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="form-control mt-4">
|
|
||||||
<%= f.button button_title(title: 'Save'), class: 'base-button' %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
<div class="max-w-lg mx-auto px-2">
|
||||||
|
<h1 class="text-4xl font-bold text-center mt-8">Setup 2FA</h1>
|
||||||
|
<%= render 'mfa_setup/form' %>
|
||||||
|
</div>
|
||||||
Loading…
Reference in new issue