我正在开发一个应用程序,允许您通过Facebook进行身份验证以注册并登录到应用程序 . 由于某些原因,当使用多个dynos时,似乎会话管理不会被继承 .

我可以看到我的日志记录用户,但是当用户被重定向时,应用程序会出于某种原因将用户注销

这是我的AuthorizationsController:

class AuthorizationsController < ApplicationController
  skip_before_filter :redirect_to_signed_in_path, :prepare_for_mobile, :redirect_to_https, :force_www!

  def create
    authentication = Authorization.find_by_provider_and_uid(auth['provider'], auth['uid'])

    if authentication
      flash[:notice] = "Signed In Successfully"
      sign_in authentication.user, event: :authentication
      redirect_to root_path
    elsif user_signed_in?
      current_user.apply_omniauth(auth)

      if current_user.save
        current_user.update_attribute(:"allow_#{auth['provider']}_sync", true)
        PullSocialActionsWorker.perform_async(current_user.id, auth["provider"])
        redirect_to edit_social_profile_path, flash: { error: "#{auth["provider"]} Integration is processing" }
      else
        redirect_to edit_social_profile_path, flash: { error: "An error has occurred. Please try again." }
      end

    else
      password = Devise.friendly_token[0,20]
      athlete = Athlete.new(email: generate_auth_email(params[:provider]), password: password, password_confirmation: password )
      athlete.apply_omniauth(auth)

      begin
        athlete.subscriptions.build(trial_expiry: DateTime.now + 30, active: true, account_type_id: AccountType.free.id)
        if athlete.save(validate: false)
          sign_in athlete, event: :authentication
          redirect_to root_path, notice: "Account created and signed in successfully"
        else
          redirect_to root_path, flash: { error: "An error has occurred. Please try again." }
        end
      rescue ActiveRecord::RecordNotUnique
        redirect_to root_path, flash: { error: "The email address you are trying to connect already exists. Perhaps you #{ActionController::Base.helpers.link_to "Forgot Your Password?", new_user_password_path}".html_safe }
      end
    end
  end

  def failure
    redirect_to root_url, notice: "An Error has occurred. Please try again!"
  end

  private

    def auth
      request.env["omniauth.auth"]
    end

    def generate_auth_email(provider)
      if provider == "twitter"
        "#{auth.uid}@twitter.com"
      else
        auth.info.try(:email)
      end
    end

end

的Gemfile:

gem 'omniauth'
gem 'omniauth-facebook', '1.4.0'

我也使用Memcache / Dalli进行缓存......

gem 'memcachier'
gem 'dalli'

其他人之前遇到过这个问题吗?