summaryrefslogtreecommitdiff
path: root/app/models/personal_access_token.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/personal_access_token.rb')
-rw-r--r--app/models/personal_access_token.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/personal_access_token.rb b/app/models/personal_access_token.rb
index 3b07551fe05..ad2f4525171 100644
--- a/app/models/personal_access_token.rb
+++ b/app/models/personal_access_token.rb
@@ -4,6 +4,7 @@ class PersonalAccessToken < ApplicationRecord
include Expirable
include TokenAuthenticatable
include Sortable
+ include EachBatch
extend ::Gitlab::Utils::Override
add_authentication_token_field :token, digest: true
@@ -97,6 +98,10 @@ class PersonalAccessToken < ApplicationRecord
end
def set_default_scopes
+ # When only loading a select set of attributes, for example using `EachBatch`,
+ # the `scopes` attribute is not present, so we can't initialize it.
+ return unless has_attribute?(:scopes)
+
self.scopes = Gitlab::Auth::DEFAULT_SCOPES if self.scopes.empty?
end