2018-01-15 00:10:48 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
|
|
module Auth
|
|
|
|
class BlockedUserTracker
|
2018-08-01 09:56:44 -04:00
|
|
|
def initialize(user, auth)
|
|
|
|
@user = user
|
|
|
|
@auth = auth
|
2018-07-20 10:00:28 -04:00
|
|
|
end
|
2018-01-15 00:10:48 -05:00
|
|
|
|
2018-08-01 11:08:59 -04:00
|
|
|
def log_activity!
|
2018-08-01 09:56:44 -04:00
|
|
|
return unless @user.blocked?
|
2018-07-27 07:54:31 -04:00
|
|
|
|
2018-08-01 09:56:44 -04:00
|
|
|
Gitlab::AppLogger.info <<~INFO
|
|
|
|
"Failed login for blocked user: user=#{@user.username} ip=#{@auth.request.ip}")
|
|
|
|
INFO
|
2018-07-27 07:54:31 -04:00
|
|
|
|
2018-08-01 09:56:44 -04:00
|
|
|
SystemHooksService.new.execute_hooks_for(@user, :failed_login)
|
|
|
|
rescue TypeError
|
2018-07-27 07:54:31 -04:00
|
|
|
end
|
2018-01-15 00:10:48 -05:00
|
|
|
end
|
|
|
|
end
|
2018-08-03 06:58:00 -04:00
|
|
|
end
|