问题描述
我正在使用 作为身份验证,每次从 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/[email protected]&password=123456789&password_confirmation=123456789
这篇关于过滤器链因呈现或重定向的:validate_sign_up_params而停止-devise_token_auth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!