Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-06-19 23:31:36 +0300
committerRobert Speicher <rspeicher@gmail.com>2015-06-19 23:35:53 +0300
commit516b4c124831296a9280b9f04abcd865492eea1e (patch)
tree300022679679440235dc36576656e22ff470137b /app/models/user.rb
parente13b523c92d82d10c553a90dd0fb93b73dee3023 (diff)
Allow Admin to filter users by 2FA status
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index a2e2d220b3a..57a36a73ac5 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -193,11 +193,13 @@ class User < ActiveRecord::Base
mount_uploader :avatar, AvatarUploader
# Scopes
- scope :admins, -> { where(admin: true) }
+ scope :admins, -> { where(admin: true) }
scope :blocked, -> { with_state(:blocked) }
scope :active, -> { with_state(:active) }
scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all }
scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM members)') }
+ scope :with_two_factor, -> { where('otp_required_for_login IS true') }
+ scope :without_two_factor, -> { where('otp_required_for_login IS NOT true') }
#
# Class methods
@@ -231,9 +233,16 @@ class User < ActiveRecord::Base
def filter(filter_name)
case filter_name
- when "admins"; self.admins
- when "blocked"; self.blocked
- when "wop"; self.without_projects
+ when 'admins'
+ self.admins
+ when 'blocked'
+ self.blocked
+ when 'two_factor_disabled'
+ self.without_two_factor
+ when 'two_factor_enabled'
+ self.with_two_factor
+ when 'wop'
+ self.without_projects
else
self.active
end