【问题标题】:Filter chain halted as :validate_sign_up_params rendered or redirected - devise_token_auth过滤器链因 :validate_sign_up_params 渲染或重定向而停止 - devise_token_auth
【发布时间】:2016-05-03 00:05:46
【问题描述】:

我正在开发一个使用 devise_token_auth 作为身份验证的 ruby​​ on rails API,每次我从 postman 进行 API 调用时都会收到此错误google chrom 扩展名。以下是我的设置

宝石文件

gem 'devise'
gem 'omniauth'
gem 'devise_token_auth'
gem 'byebug'
gem 'rack-cors', :require => 'rack/cors'

routes.rb

mount_devise_token_auth_for 'User', at: 'auth'

application_controller.rb

 include DeviseTokenAuth::Concerns::SetUserByToken
    before_action :authenticate_user! , :except=>[:new, :create]

用户模型:

  devise :database_authenticatable, :registerable,
          :recoverable, :rememberable, :trackable, :validatable,
          :confirmable, :omniauthable
  include DeviseTokenAuth::Concerns::User

  after_initialize :set_provider #, :set_uid

def set_provider
    byebug
 self[:provider] = "email" if self[:provider].blank?

end


def set_uid
  byebug
  self[:uid] = self[:email] if self[:uid].blank? && self[:email].present?
end 

我有点担心为什么User Model 中的这些byebug 不起作用!哪个,因为我认为它不会模拟用户

【问题讨论】:

  • 从浏览器中删除了您的 cookie。

标签: ruby-on-rails ruby ruby-on-rails-4 postman rails-api


【解决方案1】:

实际上,就我而言,这是一个很大的错误。 validate_sign_up_params 错误是由于错误的参数而发生的,在我的情况下,我发送了正确的参数,但包裹在用户对象中,例如 user[name]user[email] 等。所以我所要做的就是打开这些并拨打如下电话:

localhost:3000/auth?email=abcd@no.co&password=123456789&password_confirmation=123456789

【讨论】:

    【解决方案2】:

    尝试将您的项目与此repo 进行比较。 我们基本上设置了相同的环境。特别是看看这个file,看看身份验证请求是如何工作的。

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-05
      • 2016-02-25
      • 2017-02-11
      • 2018-10-08
      • 1970-01-01
      相关资源
      最近更新 更多