Hi all,
I'm trying to get the Warden:Callbacks to work on a an app, so that
all user logins are recorded in a 'user_login' table, recording the
user_id, ip address and if they have logged in or out (1 or 0).
The code I have so far, in the user model is:
Warden::Manager.after_authentication do |user,auth,opts|
store=UserLogin.new(:user_id=>
user.id, :ip_address=>"123.456.789.0", :login_type=>1)
store.save
end
Warden::Manager.before_logout do |user,auth,opts|
store=UserLogin.new(:user_id=>
user.id, :ip_address=>"123.456.789.0", :login_type=>0)
store.save
end
This records the information as required, but multiple rows (varies
from 2 to 11 rows per login / logout).
Am I correct in having these callbacks in the user model? I suspect
this may be where I am going wrong with it?
Help much appreciated as always,
Paul