Skip to content

Commit

Permalink
Fix for failed first-ever logins on PostgreSQL where column default i…
Browse files Browse the repository at this point in the history
…s nil

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
bensie authored and josevalim committed Sep 24, 2010
1 parent 7c51ec0 commit 374948c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/devise/models/lockable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def valid_for_authentication?
when TrueClass
self.failed_attempts = 0
when FalseClass
# PostgreSQL uses nil as the default value for integer columns set to 0
self.failed_attempts ||= 0
self.failed_attempts += 1
if attempts_exceeded?
lock_access!
Expand Down

0 comments on commit 374948c

Please sign in to comment.