기본 AdminUser 중 하나 대신 User 모델을 사용하는 ActiveAdmin 앱이 있습니다.ActiveAdmin with Devise는 로그인시 authentication_token을 반환하지 않습니다.
class User < ActiveRecord::Base
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable,
:token_authenticatable
attr_accessible :email, :password, :password_confirmation, :remember_me, :role
has_and_belongs_to_many :groups
has_many :items, :through => :groups
before_save :ensure_authentication_token
def is_admin?
@role.eql?("admin") ? true : false
end
end
설정/routes.rb :
DeviseCreateUser 마이그레이션에서Lao::Application.routes.draw do
ActiveAdmin.routes(self)
devise_for :users, ActiveAdmin::Devise.config
end
, 내가 추가 한 : 사용자는 응용 프로그램/모델/user.rb이
(공백 또는 관리자) 역할을한다
## Token authenticatable
t.string :authentication_token
다음 HTTP POST 요청을 통해 로그하는 경우 :
curl -H 'Content-Type: application/json' -H 'Accept: application/json' -XPOST http://localhost:3000/admin/login.json -d '{"user" : {"email" : "[email protected]", "password" : "password"}}'
나는 인증 토큰을 얻을하지 않습니다
=> {"created_at":"2013-04-17T17:11:38Z","email":"[email protected]","id":2,"role":null,"updated_at":"2013-04-17T17:53:37Z"}
내가 응답의 인증 토큰을 얻을 수있는 방법
? 나는 "created_at", "email", "id", "role"및 "updated_at"필드가 발송 된 이유를 알 수 없습니다. 이 목록을 어떻게 바꿀 수 있습니까?