过滤器链因呈现或重定向的:validate_sign_up_params而停止-devise_token_auth [英] Filter chain halted as :validate_sign_up_params rendered or redirected - devise_token_auth

查看:109
本文介绍了过滤器链因呈现或重定向的:validate_sign_up_params而停止-devise_token_auth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 devise_token_auth 作为身份验证,每次从 postman google chrom 扩展名进行API调用时,都会出现此错误。以下是我的设置

I'm working on a ruby on rails API using devise_token_auth as authentication , and i'm getting this error everytime i'm making a API call from postman google chrom extension .below are my settings

Gemfile

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

routes.rb

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 

我有点担心为什么这些 用户模型中的byebug 无法正常工作!其中,因为我认为这不是模型用户

and i'm a little worried that why these byebug in the User Model are not working ! which ,because i think that it's not coming to model user

推荐答案

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

Actually it was a big blunder in my case . validate_sign_up_params error occurs due to wrong parameters , in my case i was sending right parameters but wrapped in user object like user[name] , user[email] etc . so all i have to do was to unwrap these and make the call like below:

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

这篇关于过滤器链因呈现或重定向的:validate_sign_up_params而停止-devise_token_auth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆