You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
734 B

  1. # frozen_string_literal: true
  2. class Settings::TwoFactorAuthsController < ApplicationController
  3. layout 'admin'
  4. before_action :authenticate_user!
  5. def show
  6. return unless current_user.otp_required_for_login
  7. @provision_url = current_user.otp_provisioning_uri(current_user.email, issuer: Rails.configuration.x.local_domain)
  8. @qrcode = RQRCode::QRCode.new(@provision_url)
  9. end
  10. def enable
  11. current_user.otp_required_for_login = true
  12. current_user.otp_secret = User.generate_otp_secret
  13. current_user.save!
  14. redirect_to settings_two_factor_auth_path
  15. end
  16. def disable
  17. current_user.otp_required_for_login = false
  18. current_user.save!
  19. redirect_to settings_two_factor_auth_path
  20. end
  21. end