blob: a30220b693426af3032e71c2235298de6e004e15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
module UserMentions
module Models
# isolated Namespace model
class User < ActiveRecord::Base
include Concerns::IsolatedFeatureGate
self.table_name = 'users'
self.inheritance_column = :_type_disabled
has_many :project_authorizations, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
def authorizations_for_projects(min_access_level: nil, related_project_column: 'projects.id')
authorizations = project_authorizations
.select(1)
.where("project_authorizations.project_id = #{related_project_column}")
return authorizations unless min_access_level.present?
authorizations.where('project_authorizations.access_level >= ?', min_access_level)
end
def can_read_all_resources?
can?(:read_all_resources)
end
def can?(action, subject = :global)
Ability.allowed?(self, action, subject)
end
end
end
end
end
end
|