]> source.dussan.org Git - redmine.git/commitdiff
Don't compare timestamps with 0, triggers SQL errors with PostgreSQL (#10840).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 12 Jan 2017 22:20:46 +0000 (22:20 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 12 Jan 2017 22:20:46 +0000 (22:20 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@16175 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/token.rb

index 7966220530ce72c7374957f8293c46b9cea78a84..45703a0856cf2388700226e85b43bf17e47ee22d 100644 (file)
@@ -48,7 +48,8 @@ class Token < ActiveRecord::Base
 
   # Return true if token has expired
   def expired?
-    return created_on < self.class.invalid_when_created_before(action)
+    validity_time = self.class.invalid_when_created_before(action)
+    validity_time.present? && created_on < validity_time
   end
 
   def max_instances
@@ -63,9 +64,7 @@ class Token < ActiveRecord::Base
       validity_time = self.validity_time
     end
 
-    if validity_time.nil?
-      0
-    else
+    if validity_time
       Time.now - validity_time
     end
   end