Devise log after auth failure

后端 未结 6 2126
梦谈多话
梦谈多话 2020-12-09 00:07

I need to write a log when somebody failes to log in to my app (to track bruteforce attempts). Also I decided to log successful authentications. So I created a Sess

6条回答
  •  时光取名叫无心
    2020-12-09 00:30

    For logout logging, you need to catch the destroy event, so add the following to the Session controller (from the above answer):

    before_filter :log_logout, :only => :destroy  #add this at the top with the other filters
    
    def log_logout
         ::Rails.logger.info "*** Logging out : #{current_user.email} ***\n"  
    end
    

提交回复
热议问题