diff --git a/app/controllers/devise_otp/devise/otp_tokens_controller.rb b/app/controllers/devise_otp/devise/otp_tokens_controller.rb
index 1fe1bad..c80aa7a 100644
--- a/app/controllers/devise_otp/devise/otp_tokens_controller.rb
+++ b/app/controllers/devise_otp/devise/otp_tokens_controller.rb
@@ -45,7 +45,6 @@ def update
#
def destroy
if resource.disable_otp!
- resource.clear_otp_fields!
otp_set_flash_message :success, :successfully_disabled_otp
end
diff --git a/app/views/devise/otp_tokens/_token_secret.html.erb b/app/views/devise/otp_tokens/_token_secret.html.erb
index 135819f..a8c6a3c 100644
--- a/app/views/devise/otp_tokens/_token_secret.html.erb
+++ b/app/views/devise/otp_tokens/_token_secret.html.erb
@@ -7,13 +7,6 @@
<%= resource.otp_auth_secret %>
<%= button_to I18n.t('disable_link', :scope => 'devise.otp.otp_tokens'), @resource, :method => :delete, :data => { "turbo-method": "DELETE" } %>
- -- <%= I18n.t('disable_explain', :scope => 'devise.otp.otp_tokens') %> - <%= I18n.t('disable_explain_warn', :scope => 'devise.otp.otp_tokens') %> -
-<%= button_to I18n.t('reset_link', :scope => 'devise.otp.otp_tokens'), reset_otp_token_path_for(resource), :method => :post , :data => { "turbo-method": "POST" } %>
diff --git a/app/views/devise/otp_tokens/show.html.erb b/app/views/devise/otp_tokens/show.html.erb index 8ca6d0a..5a663c2 100644 --- a/app/views/devise/otp_tokens/show.html.erb +++ b/app/views/devise/otp_tokens/show.html.erb @@ -5,6 +5,10 @@ <%- if resource.otp_enabled? %> <%= render :partial => 'token_secret' if resource.otp_enabled? %> <%= render :partial => 'trusted_devices' if trusted_devices_enabled? %> + + <% unless otp_mandatory_on?(resource) %> + <%= button_to I18n.t('disable_link', :scope => 'devise.otp.otp_tokens'), @resource, :method => :delete, :data => { "turbo-method": "DELETE" } %> + <% end %> <% else %> <%= link_to I18n.t('enable_link', :scope => 'devise.otp.otp_tokens'), edit_otp_token_path_for(resource) %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 426662d..40e17cb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,8 +30,6 @@ en: title: 'Two-factors Authentication:' enable_link: 'Enable Two-Factor Authentication' disable_link: 'Disable Two-Factor Authentication' - disable_explain: 'This will disable Two-Factor authentication and clear the OTP secret.' - disable_explain_warn: 'To re-enable Two-Factor authentication, you will need to enroll your mobile device again.' reset_link: 'Reset Token Secret' reset_explain: 'Resetting your token secret will temporarilly disable Two-Factor authentication.' reset_explain_warn: 'To re-enable Two-Factor authentication, you will need to re-enroll your mobile device with the new token secret.' diff --git a/lib/devise_otp_authenticatable/engine.rb b/lib/devise_otp_authenticatable/engine.rb index 035c83a..6b9f168 100644 --- a/lib/devise_otp_authenticatable/engine.rb +++ b/lib/devise_otp_authenticatable/engine.rb @@ -12,11 +12,13 @@ class Engine < ::Rails::Engine ActiveSupport.on_load(:devise_controller) do include DeviseOtpAuthenticatable::Controllers::UrlHelpers include DeviseOtpAuthenticatable::Controllers::Helpers + include DeviseOtpAuthenticatable::Controllers::PublicHelpers end ActiveSupport.on_load(:action_view) do include DeviseOtpAuthenticatable::Controllers::UrlHelpers include DeviseOtpAuthenticatable::Controllers::Helpers + include DeviseOtpAuthenticatable::Controllers::PublicHelpers end # See: https://guides.rubyonrails.org/engines.html#separate-assets-and-precompiling