Mani
Mani

Reputation: 2553

Filter chain halted as :validate_sign_up_params rendered or redirected - devise_token_auth

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

Upvotes: 0

Views: 1519

Answers (2)

Mani
Mani

Reputation: 2553

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/[email protected]&password=123456789&password_confirmation=123456789

Upvotes: 1

TWONEKSONE
TWONEKSONE

Reputation: 4258

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.

Upvotes: 0

Related Questions