2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-11-05 15:09:11 +01:00
|
|
|
class SuperAdminsController < ApplicationController
|
|
|
|
before_action :authenticate_super_admin!
|
|
|
|
|
2024-09-11 15:13:32 +02:00
|
|
|
def nav_bar_profile = :superadmin
|
|
|
|
|
2020-11-05 15:09:11 +01:00
|
|
|
def edit_otp
|
|
|
|
end
|
|
|
|
|
|
|
|
def enable_otp
|
|
|
|
current_super_admin.enable_otp!
|
|
|
|
@qrcode = generate_qr_code
|
|
|
|
sign_out :super_admin
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def authenticate_super_admin!
|
|
|
|
if !super_admin_signed_in?
|
|
|
|
redirect_to root_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def generate_qr_code
|
|
|
|
issuer = 'DSManager'
|
2020-11-25 18:16:32 +01:00
|
|
|
|
|
|
|
if Rails.env.development?
|
|
|
|
issuer += " (local)"
|
2021-02-11 11:14:14 +01:00
|
|
|
elsif helpers.staging?
|
2020-11-25 18:16:32 +01:00
|
|
|
issuer += " (dev)"
|
|
|
|
end
|
|
|
|
|
2020-11-05 15:09:11 +01:00
|
|
|
label = "#{issuer}:#{current_super_admin.email}"
|
|
|
|
RQRCode::QRCode.new(current_super_admin.otp_provisioning_uri(label, issuer: issuer))
|
|
|
|
end
|
|
|
|
end
|