Filter chain halted as :validate_sign_up_params rendered or redirected - devise_token_auth

丶灬走出姿态 提交于 2020-01-07 04:44:10

问题


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

mount_devise_token_auth_for 'User', at: 'auth'

application_controller.rb

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

User model:

  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 

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


回答1:


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



回答2:


Try to compare your project with this repo. We basically setup the same environment. In particular take a look at this file to see how an authenticate request work.



来源:https://stackoverflow.com/questions/35013635/filter-chain-halted-as-validate-sign-up-params-rendered-or-redirected-devise

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!