Sha256: bbd30e3078af6440ad15a9660c14d8e9357f0e99bd9639db19b363cf4706c459

Contents?: true

Size: 808 Bytes

Versions: 4

Compression:

Stored size: 808 Bytes

Contents

# frozen_string_literal

# Helper for one-time-password authentication methods
#
# Automatically generated by the orthodox gem (https://github.com/katanacode/orthodox)
# (c) Copyright 2019 Katana Code Ltd. All Rights Reserved. 
module OtpCredentialsHelper

  require 'rqrcode'

  # SVG code for a given OtpCredential. Use this to add a QR code to a page
  #
  # otp_credential - An OtpCredential to show the SVG for.
  #
  # Retuns String of valid HTML
  def svg_url_for_otp_credential(otp_credential)
    qrcode = qrcode(otp_credential)
    qrcode.as_svg({
      offset: 0,
      color: '000',
      shape_rendering: 'crispEdges',
      module_size: 3,
      standalone: true      
    }).html_safe
  end

  private
  
  def qrcode(otp_credential)
    RQRCode::QRCode.new(otp_credential.url)
  end
    
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
orthodox-0.3.3 lib/generators/authentication/templates/helpers/otp_credentials_helper.rb
orthodox-0.3.2 lib/generators/authentication/templates/helpers/otp_credentials_helper.rb
orthodox-0.3.1 lib/generators/authentication/templates/helpers/otp_credentials_helper.rb
orthodox-0.3.0 lib/generators/authentication/templates/helpers/otp_credentials_helper.rb