diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-08-02 19:43:36 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-08-02 19:43:36 +0200 |
commit | a6268d302379258b1a2bf50f7db87b40e84ffe94 (patch) | |
tree | 2af5bd8ff3e095310a3745451ce7d1547d81f6e4 /app/models/deploy_token.rb | |
parent | 367e7520b08b1b731d5298fe700fc39f356017ce (diff) | |
download | gitlab-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.rb | 8 |
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 |