Module: Booth::Models::Concerns::Otpable

Extended by:
ActiveSupport::Concern
Included in:
Booth::Models::Credential, Onboarding
Defined in:
lib/booth/models/concerns/otpable.rb

Instance Method Summary collapse

Instance Method Details

#authenticate_otp(code) ⇒ Object



18
19
20
# File 'lib/booth/models/concerns/otpable.rb', line 18

def authenticate_otp(code)
  super(code, drift: 30.seconds)
end

#otp_provisioning_svgObject



28
29
30
31
32
33
# File 'lib/booth/models/concerns/otpable.rb', line 28

def otp_provisioning_svg
  qr = ::RQRCode::QRCode.new(otp_provisioning_url, level: :l)
  # See https://whomwah.github.io/rqrcode/
  qr.as_svg use_path: false,
            viewbox: true, fill: 'fff', offset: 5, module_size: 8, svg_attributes: { 'data-booth' => :otpqr }
end

#otp_provisioning_urlObject



22
23
24
25
26
# File 'lib/booth/models/concerns/otpable.rb', line 22

def otp_provisioning_url
  raise "Expected #{self} to respond to #scope" unless respond_to?(:scope)

  provisioning_uri(username, issuer: ::Booth.config.otp_issuer(scope:), digits: otp_digits)
end