Skip to content

Commit

Permalink
Fix bug in last_otp_at definition
Browse files Browse the repository at this point in the history
The rotp gem sets this value to an integer, but setting a datetime field to an
integer causes it to be silently set to null.  Make this value an integer instead.
  • Loading branch information
skomanduri committed Oct 9, 2017
1 parent c0da5d0 commit 3512bb5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion demo/db/migrate/20170516191259_add_lastotpat_to_users.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddLastotpatToUsers < ActiveRecord::Migration
def change
add_column :users, :last_otp_at, :datetime
add_column :users, :last_otp_at, :integer
end
end
1 change: 1 addition & 0 deletions demo/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
t.string "encrypted_otp_secret_salt"
t.integer "consumed_timestep"
t.boolean "otp_required_for_login"
t.integer "last_otp_at"
end

add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
Timecop.travel(subject.otp.interval.seconds.from_now)
end

# This currently fails!
# This spec tests that reuse of the OTP is not allowed
it 'fails to validate' do
expect(subject.validate_and_consume_otp!(consumed_otp)).to be false
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create_devise_two_factor_migration
"encrypted_otp_secret_iv:string",
"encrypted_otp_secret_salt:string",
"consumed_timestep:integer",
"last_otp_at:datetime",
"last_otp_at:integer",
"otp_required_for_login:boolean"
]

Expand Down

0 comments on commit 3512bb5

Please sign in to comment.