简体   繁体   中英

Need To redirect At home page If user Already logged in

i am using omniauth with devise . my controller is bellow

 class OmniauthCallbacksController < Devise::OmniauthCallbacksController
      def facebook
        # You need to implement the method below in your model (e.g. app/models/user.rb)
        @user = User.from_omniauth(request.env["omniauth.auth"])



        if @user.persisted?
          sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
          set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
        else
          # session["devise.facebook_data"] = request.env["omniauth.auth"]
          redirect_to new_user_registration_url
        end
      end
    end

this redirect the user to signup page if user already signin and persist.what i make change to redirect the user at home page.......????? help me out please

Have set after sign_in path ?

#application_controller.rb
def after_sign_in_path_for(resource_or_scope)
  case resource_or_scope
  when :user, User

    root_path
  else
    super
  end
end

Example Rails devise with omniauth

Code Example

if you facing other errors please paste here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM