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

Not writing to database with auto_increment: true #67

Closed bartpalmtree closed 4 years ago

bartpalmtree commented 4 years ago

When using auto_increment it wouldn't save the model. It would continue as persisted and not new_record, but was flagged changed. When I had a different instance of the user the counter would never match, but always be zero.

If I only used the in-memory/cached user object then it would work just fine. E.g., u = User.find(1) u.otp_counter #=> 0 u.otp_code() #=> "226630" u.otp_code(auto_increment: true) #=> "279079" u.otp_counter #=> 1 u = User.find(1) u.otp_counter #=> 0 (expected 1)

bartpalmtree commented 4 years ago

Thanks!!