Added optional two-factor authentication
This commit is contained in:
parent
237cb41ab4
commit
ba192f12e3
16 changed files with 146 additions and 15 deletions
28
app/controllers/settings/two_factor_auths_controller.rb
Normal file
28
app/controllers/settings/two_factor_auths_controller.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Settings::TwoFactorAuthsController < ApplicationController
|
||||
layout 'auth'
|
||||
|
||||
before_action :authenticate_user!
|
||||
|
||||
def show
|
||||
return unless current_user.otp_required_for_login
|
||||
|
||||
@qrcode = RQRCode::QRCode.new(current_user.otp_provisioning_uri(current_user.email, issuer: Rails.configuration.x.local_domain))
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue