diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-06-07 12:20:57 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-06-07 12:20:57 +0300 |
commit | 7adddf49965a1808e7a3a0d1a70b08172c74a762 (patch) | |
tree | 326fd31a0b2ac01fd31d71b0d2e9146d363bb967 /app/models/personal_access_token.rb | |
parent | dddc54aa0aea4088e5a233d18a62cb2435590fe9 (diff) | |
parent | 9fcc3e5982311a380681c822df72fe470a5ea1ca (diff) |
Merge branch 'zj-read-registry-pat' into 'master'
Allow pulling container images using personal access tokens
Closes #19219
See merge request !11845
Diffstat (limited to 'app/models/personal_access_token.rb')
-rw-r--r-- | app/models/personal_access_token.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/app/models/personal_access_token.rb b/app/models/personal_access_token.rb index ae9f71e7747..6e13f9b2089 100644 --- a/app/models/personal_access_token.rb +++ b/app/models/personal_access_token.rb @@ -15,11 +15,10 @@ class PersonalAccessToken < ActiveRecord::Base scope :without_impersonation, -> { where(impersonation: false) } validates :scopes, presence: true - validate :validate_api_scopes + validate :validate_scopes def revoke! - self.revoked = true - self.save + update!(revoked: true) end def active? @@ -28,9 +27,9 @@ class PersonalAccessToken < ActiveRecord::Base protected - def validate_api_scopes - unless scopes.all? { |scope| Gitlab::Auth::API_SCOPES.include?(scope.to_sym) } - errors.add :scopes, "can only contain API scopes" + def validate_scopes + unless scopes.all? { |scope| Gitlab::Auth::AVAILABLE_SCOPES.include?(scope.to_sym) } + errors.add :scopes, "can only contain available scopes" end end end |