app/models/educator_multifactor_config.rb
# This has to be valid base32, so to validate that instantiate one and see if it raises.
# Check this for a time in the past, so that it can't leak a code.
This has to be valid base32, so to validate that instantiate one and see if it raises.
Check this for a time in the past, so that it can't leak a code.
This has to be valid base32 so to validate that instantiate one and see if it raises . Check this for a time in the past so that it can ' t leak a code .
def validate_rotp_secret
    return if errors.present?
    begin
      totp = ROTP::TOTP.new(self.rotp_secret)
      totp.at(Time.at(1474590600))
    rescue ROTP::Base32::Base32Error => _
      errors.add(:rotp_secret, 'not valid base32')
    end
  end
def validate_rotp_secret return if errors . present? begin totp = ROTP :: TOTP . new ( self . rotp_secret ) totp . at ( Time . at ( 1474590600 ) ) rescue ROTP :: Base32 :: Base32Error => _ errors . add ( :rotp_secret , 'not valid base32' ) end end
This has to be valid base32, so to validate that instantiate one and see if it raises.
This has to be valid base32 so to validate that instantiate one and see if it raises .