Search code examples
ruby-on-railssorcery

Sign in user on signup with Sorcery


I have authentication working with Sorcery. When users sign up, I want to automatically sign them in.

User_controller

def create
@user = User.new(params[:user])

if @user.save
  flash[:success] = "Welcome to Christian"
  redirect_to root_url
else
  render :new
end

end


Solution

  • auto_login(user) should do the trick:

    ...
    
    if @user.save
      auto_login(@user)
      flash[:success] = "Welcome to Christian"
      redirect_to root_url
    
    ...