Closed hkairi closed 10 years ago
Latest version gives me a sane error.. a ROTP::Base32::Base32Error as expected, this could be closed I guess.
puts "Current code #{user.otp_code}" ROTP::Base32::Base32Error: Invalid Base32 Character - '!' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/base32.rb:46:in
decode_quint' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/base32.rb:28:in
block in decode_block' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/base32.rb:28:ineach_char' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/base32.rb:28:in
each' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/base32.rb:28:inmap' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/base32.rb:28:in
decode_block' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/base32.rb:10:inblock in decode' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/base32.rb:9:in
each' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/base32.rb:9:indecode' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/otp.rb:49:in
byte_secret' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/otp.rb:26:ingenerate_otp' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/rotp-1.5.0/lib/rotp/totp.rb:24:in
at' from /Users/andrehjr/.rvm/gems/ruby-1.9.3-p327/gems/active_model_otp-0.0.1/lib/active_model/one_time_password.rb:31:inotp_code' from (irb):16 from /Users/andrehjr/.rvm/rubies/ruby-1.9.3-p327/bin/irb:16:in
'
@andrehjr right :+1:
require "active_model_otp"
class User extend ActiveModel::Callbacks include ActiveModel::Validations include ActiveModel::OneTimePassword
define_model_callbacks :create attr_accessor :otp_secret_key, :email
has_one_time_password end
user = User.new user.email = 'roberto@heapsource.com' user.otp_secret_key = "anotherfakeOTPSecretKey!!" puts "Current code #{user.otp_code}"
I am having this issue everytime the OTP secret key is containing non ASCII characters or numbers
.../rotp-1.4.1/lib/rotp/base32.rb:37:in `+': nil can't be coerced into Fixnum (TypeError)