我正在使用 devise_token_auth 作为身份验证在rails上运行ruby,我每次从 postman google chrom 扩展名。下面是我的设置
的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]
用户模型:
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
中的这些User Model
无效!因为我认为它不是模型用户