2017-01-27 20:28:46 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Settings::TwoFactorAuthsController < ApplicationController
|
2017-01-28 03:56:10 +01:00
|
|
|
layout 'admin'
|
2017-01-27 20:28:46 +01:00
|
|
|
|
|
|
|
before_action :authenticate_user!
|
|
|
|
|
|
|
|
def show
|
|
|
|
return unless current_user.otp_required_for_login
|
|
|
|
|
2017-02-13 20:56:03 +01:00
|
|
|
@provision_url = current_user.otp_provisioning_uri(current_user.email, issuer: Rails.configuration.x.local_domain)
|
|
|
|
@qrcode = RQRCode::QRCode.new(@provision_url)
|
2017-01-27 20:28:46 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def enable
|
|
|
|
current_user.otp_required_for_login = true
|
|
|
|
current_user.otp_secret = User.generate_otp_secret
|
|
|
|
current_user.save!
|
|
|
|
|
|
|
|
redirect_to settings_two_factor_auth_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def disable
|
|
|
|
current_user.otp_required_for_login = false
|
|
|
|
current_user.save!
|
|
|
|
|
|
|
|
redirect_to settings_two_factor_auth_path
|
|
|
|
end
|
|
|
|
end
|