autologin in authlogic Rails
I have added auhlogic in my Rails app to authenticate users. I have also included the code from the Reset password tutorial . All of it works, the only issue I have is that once a user registers he gets automatically logged in.
Anyone worked with authlogic, what would be the best & fastest way to disable the autologin after the registrat开发者_StackOverflow中文版ion?
You can use #save_without_session_maintenance:
@user = User.new(params[:user])
@user.save_without_session_maintenance
If you will use this way:
After registration save succeeds,
session = UserSession.find
session.destroy if session
You probably can loss your Admin session, who perhaps adding the user.
So, the better way will be is just to add some options to your model user.rb:
acts_as_authentic do |c|
c.maintain_sessions = false
#for more options check the AuthLogic documentation
end
Now it should work.
After registration save succeeds,
session = UserSession.find
session.destroy if session
精彩评论