i pulling hair out trying figure out why call warden::manager.before_logout throwing nomethoderror nilclass when tried call 'user.my_method'. added debug puts call before_logout block , discovered being called twice on each logout - first time user being nil, , after, user object supplied. able inelegantly around exception changing call 'user.my_method if user', i'm still not comfortable not knowing why before_logout getting called twice. has else seen this? perhaps 1 of happens-in-development-only environment anomalies?
devise.setup |config| warden::manager.after_authentication |user,auth,opts| user.update_attributes(is_active: true) end warden::manager.before_logout |user,auth,opts| user.update_attributes(is_active: false) if user end
this old, have 2 models (scopes in warden's case): 1 user , adminuser. can use if statement model/scope want:
warden::manager.before_logout |user, auth, opts| if opts[:scope] == :user user.current_sign_in_at = nil user.save! end end
Comments
Post a Comment