Skip to content

Commit

Permalink
[frontend] Track result of login attempts
Browse files Browse the repository at this point in the history
This allows us more fine grained graphs.
  • Loading branch information
bgeuken committed Apr 27, 2018
1 parent 13299d3 commit 6b11e20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/api/app/controllers/webui/session_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ def create
user = User.find_with_credentials(params[:username], params[:password])

unless user
RabbitmqBus.send_to_bus('metrics', 'user.login,access_point=webui,result=failed,failure_reason=unauthenticated id=0')
redirect_to(session_new_path, error: 'Authentication failed')
return
end

unless user.is_active?
RabbitmqBus.send_to_bus('metrics', "user.login,access_point=webui,result=failed,failure_reason=inactive id=#{user.id}")
redirect_to(root_path, error: 'Your account is disabled. Please contact the administrator for details.')
return
end

User.current = user
session[:login] = user.login
Rails.logger.debug "Authenticated as user '#{user.login}'"
RabbitmqBus.send_to_bus('metrics', "user.login,access_point=webui,result=succeeded id=#{user.id}")

redirect_on_login
end
Expand Down
1 change: 0 additions & 1 deletion src/api/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,6 @@ def combined_rss_feed_items

def mark_login!
update_attributes(last_logged_in_at: Time.now, login_failure_count: 0)
RabbitmqBus.send_to_bus('metrics', "user.login id=#{id}")
end

private
Expand Down

0 comments on commit 6b11e20

Please sign in to comment.