diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-01-15 08:53:31 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-01-15 08:53:31 +0000 |
commit | 5e3ef30259f9d257a084ed6b72ccbd713f0f8294 (patch) | |
tree | b0febea9db2195a14de522ceb25c708476bc8104 /app | |
parent | 598d81cd3a47dee648db1f511457e3d9ba94e13d (diff) | |
parent | 0d187a9a65c5a8eae4bcb09228270cb974abd466 (diff) | |
download | gitlab-ce-5e3ef30259f9d257a084ed6b72ccbd713f0f8294.tar.gz |
Merge branch 'sh-log-when-user-blocked' into 'master'
Log and send a system hook if a blocked user attempts to login
Closes #41633
See merge request gitlab-org/gitlab-ce!16451
Diffstat (limited to 'app')
-rw-r--r-- | app/models/user.rb | 8 | ||||
-rw-r--r-- | app/services/system_hooks_service.rb | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 4484ee9ff4c..09aa5a7b318 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -53,7 +53,10 @@ class User < ActiveRecord::Base serialize :otp_backup_codes, JSON # rubocop:disable Cop/ActiveRecordSerialize devise :lockable, :recoverable, :rememberable, :trackable, - :validatable, :omniauthable, :confirmable, :registerable + :validatable, :omniauthable, :confirmable, :registerable + + BLOCKED_MESSAGE = "Your account has been blocked. Please contact your GitLab " \ + "administrator if you think this is an error.".freeze # Override Devise::Models::Trackable#update_tracked_fields! # to limit database writes to at most once every hour @@ -217,8 +220,7 @@ class User < ActiveRecord::Base end def inactive_message - "Your account has been blocked. Please contact your GitLab " \ - "administrator if you think this is an error." + BLOCKED_MESSAGE end end end diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index 690918b4a00..af6d77ef5e8 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -41,8 +41,11 @@ class SystemHooksService when User data.merge!(user_data(model)) - if event == :rename + case event + when :rename data[:old_username] = model.username_was + when :failed_login + data[:state] = model.state end when ProjectMember data.merge!(project_member_data(model)) |