app/controllers/dry_auth/omniauth_callbacks_controller.rb
# 
# Handle authentication callbacks from 3rd party providers
#
Handle authentication callbacks from 3rd party providers
Handle authentication callbacks from 3rd party providers
def all
      DryAuth.logger.info { '+' * 50 }
      user = User.from_omniauth(env["omniauth.auth"])
      if user.persisted?
        DryAuth.logger.info { 'in user.persisted? true' }
        sign_in user
      else
        DryAuth.logger.info { 'in user.persisted? false' }
        session["devise.user_attributes"] = user.attributes
      end
      DryAuth.logger.info { 'Redirecting user' }
      if request.env['omniauth.origin']
        DryAuth.logger.info { "Redirecting to #{request.env['omniauth.origin']}" }
        redirect_to request.env['omniauth.origin']
      else
        DryAuth.logger.warn { "User returned without omniauth.origin" }
        DryAuth.logger.warn { "Request referer: #{request.referer}" }
        if cookies.signed[:after_auth_url]
          DryAuth.logger.warn { "Got cookie (thankfully!)" }
          redirect_url = "/#{cookies.signed[:after_auth_url]}"
        else
          DryAuth.logger.warn { "NO cookie!" }
          redirect_url = FanClub::Engine.routes.url_helpers.handle_error_path
        end
        redirect_to redirect_url
        Rails.logger.warn { "User returned without omniauth.origin! Redirecting to #{redirect_url}" }
      end
      DryAuth.logger.info { '+' * 50 }
    end
def all DryAuth . logger . info { '+' * 50 } user = User . from_omniauth ( env [ "omniauth.auth" ] ) if user . persisted? DryAuth . logger . info { 'in user.persisted? true' } sign_in user else DryAuth . logger . info { 'in user.persisted? false' } session [ "devise.user_attributes" ] = user . attributes end DryAuth . logger . info { 'Redirecting user' } if request . env [ 'omniauth.origin' ] DryAuth . logger . info { "Redirecting to #{request.env['omniauth.origin']}" } redirect_to request . env [ 'omniauth.origin' ] else DryAuth . logger . warn { "User returned without omniauth.origin" } DryAuth . logger . warn { "Request referer: #{request.referer}" } if cookies . signed [ :after_auth_url ] DryAuth . logger . warn { "Got cookie (thankfully!)" } redirect_url = "/#{cookies.signed[:after_auth_url]}" else DryAuth . logger . warn { "NO cookie!" } redirect_url = FanClub :: Engine . routes . url_helpers . handle_error_path end redirect_to redirect_url Rails . logger . warn { "User returned without omniauth.origin! Redirecting to #{redirect_url}" } end DryAuth . logger . info { '+' * 50 } end
Handle authentication callbacks from 3rd party providers
Handle authentication callbacks from 3rd party providers
# Returns true if the record is persisted, i.e. it’s not a new record and it was not destroyed, otherwise returns false. #DryAuth.logger.warn { request.env["omniauth.auth"].to_yaml }