heapsource / active_model_otp

Adds methods to set and authenticate against one time passwords (Two-Factor Authentication). Inspired in AM::SecurePassword
MIT License
773 stars 81 forks source link

fix decision of empty #24

Closed masarakki closed 5 years ago

masarakki commented 9 years ago

can't generate secret when otp_secret_key == ''

robertomiranda commented 9 years ago

what are the cases when the otp_column is blank " "? could you paste an example for illustration?

masarakki commented 9 years ago

in my case, I created table with

 t.string :otp_secret_key, null: false, default: ''

so,

user = User.new
user.otp_secret_key
# => ""
user.save
user.otp_secret_key
# => ""

I think using blank? is better to fill blank column.

robertomiranda commented 9 years ago

@masarakki Why would you be setting the otp_secret_key manually if you have has_one_time_password declared? has_one_time_password will always generate it before create the record