summaryrefslogtreecommitdiffstats
path: root/app/models/token.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-12 22:20:46 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-12 22:20:46 +0000
commit82d96258f4418f567ebe5314f3d51c82d15efc8d (patch)
tree9000b70c3e6010f9a0cb062fc949a4f379b5f0ba /app/models/token.rb
parent5d4b5fd1f68ab7aef4ef43d82d3cb378079aed31 (diff)
downloadredmine-82d96258f4418f567ebe5314f3d51c82d15efc8d.tar.gz
redmine-82d96258f4418f567ebe5314f3d51c82d15efc8d.zip
Don't compare timestamps with 0, triggers SQL errors with PostgreSQL (#10840).
git-svn-id: http://svn.redmine.org/redmine/trunk@16175 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/token.rb')
-rw-r--r--app/models/token.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/app/models/token.rb b/app/models/token.rb
index 796622053..45703a085 100644
--- a/app/models/token.rb
+++ b/app/models/token.rb
@@ -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