Devise call backs
Does devise have call backs when a user signs in and out?
This is what I came up with:
Warden::Manager.after_authentication do |user,auth,opts|
user.update_attribute(:currently_signed_in, true)
end
Warden::Manager.before_logout do |user,auth,opts|
user.update_attribute(:currently_signed_in, false)
end
This is what I came with to track users that are currently signed in.
I'm no expert but I believe the callbacks (hooks) are at the Warden level (Devise is built on top of Warden).
after_set_user and before_logout in Warden should do the trick for you but there are other options listed in Warden::Hooks
您可以像这样覆盖应用程序控制器中的sign_in
def sign_in(*args)
super(*args)
# do whatever you want here
token = current_user.authentications.where(provider: "facebook").first.token
facebook = Koala::Facebook::API.new(token)
session[:facebook] = facebook
end
链接地址: http://www.djcxy.com/p/47436.html
下一篇: 设计回调