summaryrefslogtreecommitdiff
path: root/app/models/deploy_token.rb
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-08-02 19:43:36 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2018-08-02 19:43:36 +0200
commita6268d302379258b1a2bf50f7db87b40e84ffe94 (patch)
tree2af5bd8ff3e095310a3745451ce7d1547d81f6e4 /app/models/deploy_token.rb
parent367e7520b08b1b731d5298fe700fc39f356017ce (diff)
downloadgitlab-ce-a6268d302379258b1a2bf50f7db87b40e84ffe94.tar.gz
Fix deploy tokens without `expire_at` crashes
Diffstat (limited to 'app/models/deploy_token.rb')
-rw-r--r--app/models/deploy_token.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/deploy_token.rb b/app/models/deploy_token.rb
index c466304a827..0b2eedf3631 100644
--- a/app/models/deploy_token.rb
+++ b/app/models/deploy_token.rb
@@ -30,7 +30,7 @@ class DeployToken < ActiveRecord::Base
end
def active?
- !revoked && expires_at > Date.today
+ !revoked && !expired?
end
def scopes
@@ -63,6 +63,12 @@ class DeployToken < ActiveRecord::Base
private
+ def expired?
+ return false unless expires_at
+
+ expires_at < Date.today
+ end
+
def ensure_at_least_one_scope
errors.add(:base, "Scopes can't be blank") unless read_repository || read_registry
end