ankane / authtrail

Track Devise login activity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple login models

hurrycaner opened this issue · comments

Hi, i have 3 different login models, and i want to set different authtrail tables for each one... The readme says to use bellow code for that, where should I put that? How do I make for use different authtrail tables for different models?

AuthTrail.track_method = proc do |info|
  # code
end

Hey @hurrycaner, add this an initializer, like config/initializers/authtrail.rb. You can use the data in the info hash to write logic that uses different models.

Okay, it worked just like this 👍

AuthTrail.track_method = proc do |info|
  if info[:scope] == 'me_user'
    login_activity = Me:LoginActivity.create!(info)
    AuthTrail::GeocodeJob.perform_later(login_activity) if AuthTrail.geocode
  end
end