Sha256: 346907fd8fad3d3dc0d68a49befc7afae51faaed806e20aa46f3950ee3848030
Contents?: true
Size: 481 Bytes
Versions: 56
Compression:
Stored size: 481 Bytes
Contents
require 'rotp' module EtFakeCcd module Validator class OtpValidator < ActiveModel::EachValidator def initialize(secret: ::EtFakeCcd.config.microservice_secret, **args) self.otp = ROTP::TOTP.new(secret) super end def validate_each(record, attribute, value) record.errors.add :one_time_password, 'Invalid oneTimePassword' unless otp.verify(value, drift_behind: 15) end private attr_accessor :otp end end end
Version data entries
56 entries across 56 versions & 1 rubygems