The code powering m.abunchtell.com https://m.abunchtell.com
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
690 B

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