views:

309

answers:

3

Hello,

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 registration?

+1  A: 

After registration save succeeds,

session = UserSession.find
session.destroy if session
Jonathan Julian
A: 

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.

Sergei
+2  A: 

You can use #save_without_session_maintenance:

@user = User.new(params[:user])
@user.save_without_session_maintenance
Ptico