summaryrefslogtreecommitdiff
path: root/app/models/group.rb
diff options
context:
space:
mode:
authorMarkus Koller <markus-koller@gmx.ch>2017-01-24 22:09:58 +0100
committerAlexis Reigel <mail@koffeinfrei.org>2017-04-06 10:01:13 +0200
commita3430f011f1adceaef8484f38a57018712a18ad2 (patch)
treeae69438c98358e214c39517ad4ceddf60d15c65a /app/models/group.rb
parent57374feabe1428b2ea06a6a3cac244612128095d (diff)
downloadgitlab-ce-a3430f011f1adceaef8484f38a57018712a18ad2.tar.gz
Support 2FA requirement per-group
Diffstat (limited to 'app/models/group.rb')
-rw-r--r--app/models/group.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 60274386103..106084175ff 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -27,11 +27,14 @@ class Group < Namespace
validates :avatar, file_size: { maximum: 200.kilobytes.to_i }
+ validates :two_factor_grace_period, presence: true, numericality: { greater_than_or_equal_to: 0 }
+
mount_uploader :avatar, AvatarUploader
has_many :uploads, as: :model, dependent: :destroy
after_create :post_create_hook
after_destroy :post_destroy_hook
+ after_save :update_two_factor_requirement
class << self
# Searches for groups matching the given query.
@@ -223,4 +226,12 @@ class Group < Namespace
type: public? ? 'O' : 'I' # Open vs Invite-only
}
end
+
+ protected
+
+ def update_two_factor_requirement
+ return unless require_two_factor_authentication_changed? || two_factor_grace_period_changed?
+
+ users.find_each(&:update_two_factor_requirement)
+ end
end