2

This is my sessions controller

class SessionsController <  Clearance::SessionsController
  include ActionView::Layouts
  include ActionController::Flash

  def create
    user = AdminUser.find_or_create_from_auth_hash(request.env['omniauth.auth'])
    sign_in(user)
    redirect_to admin_dashboard_index_path
  end
end

for some reason my current_user is nil when redirected to admin_dashboard_index_path. I have require_login in all other controllers. So the AD login gets into an indefinite loop. Am I missing any configuration ? All my other controllers are inherting from AdminController which inherits from ActionController::Base

SureshCS
  • 1,005
  • 12
  • 23
  • are you able to find `user` in you're session controller create action? – uday May 01 '19 at 09:32
  • @uday yes, current_user is there in my sessions controller but disappears after redirect – SureshCS May 01 '19 at 12:30
  • what is the response you're getting for `sign_in(user)` ? – uday May 01 '19 at 12:31
  • True and it sets the current_user in my sessions controller. When I redirect after sign_in the current_user is set to nil.Please note all my other controllers inherit from AdminController(which inturn inherits from ActionController::Base) and not ApplicationController – SureshCS May 01 '19 at 12:34
  • that should update the user in session but have you tried changing the inheritance to ApplicationController for Admin thing? – uday May 01 '19 at 12:56
  • No, my appication controller inherts from ActionController Api(since the app was an API app initially) and AdminController from ActionController Base. Is there any workaround for this ? – SureshCS May 01 '19 at 13:02

0 Answers0