Rails 4-devise在开发模式下工作,但不在生产模式下工作

问题描述 投票:0回答:0

我的devise / omniauth在我的开发模式下工作(尝试设置3.5年后)。

当我进入生产环境并尝试登录时,出现以下错误:

app/models/user.rb:159:in `find_for_oauth'
2016-06-26T00:24:21.173282+00:00 app[web.1]: 
2016-06-26T00:24:21.173264+00:00 app[web.1]: 
2016-06-26T00:24:21.173279+00:00 app[web.1]: Net::SMTPFatalError (553-5.1.2 The recipient address <change@me-114727432687651490566-google_oauth2.c

我的用户模型的第159行包含:

    user.save!

该行是使用以下方法的最后步骤之一:

 def self.find_for_oauth(auth, signed_in_resource = nil)
    # Get the identity and user if they exist
    identity = Identity.find_for_oauth(auth)

    # If a signed_in_resource is provided it always overrides the existing user
    # to prevent the identity being locked with accidentally created accounts.
    # Note that this may leave zombie accounts (with no associated identity) which
    # can be cleaned up at a later date.
    user = signed_in_resource ? signed_in_resource : identity.user

    # p '11111'

    # Create the user if needed
    if user.nil?
      # p 22222
      # Get the existing user by email if the provider gives us a verified email.
      # If no verified email was provided we assign a temporary email and ask the
      # user to verify it on the next step via UsersController.finish_signup
      email_is_verified = auth.info.email && (auth.info.verified || auth.info.verified_email)
      email = auth.info.email if email_is_verified # take out this if stmt for chin yi's solution
      user = User.where(:email => email).first if email

      # Create the user if it's a new registration
      if user.nil?
        # p 33333
        user = User.new(
          # at least one problem with this is that each provider uses different terms to desribe first name/last name/email. See notes on linkedin above
          first_name: auth.info.first_name,
          last_name: auth.info.last_name,
          email: email ? email : "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com",
          #username: auth.info.nickname || auth.uid,
          password: Devise.friendly_token[0,20])
# fallback for name fields - add nickname to user table
        # debugger

        if email_is_verified
           user.skip_confirmation!
        end
        # user.skip_confirmation! 

        user.save!
      end
    end

    # Associate the identity with the user if needed
    if identity.user != user
      identity.user = user
      identity.save!
    end
    user
  end

谁能看到我需要做些什么才能使其在生产模式下工作?

ruby-on-rails ruby devise omniauth dev-to-production
© www.soinside.com 2019 - 2024. All rights reserved.