Ember Simple Auth (Devise) 更新后,authenticate_with_http_token 始终为空

Ember Simple Auth (Devise) after update, authenticate_with_http_token alway empty

我使用 ember-simple-authfor for devise 从 0.7.2 更新到 1.0.1。参考资源:https://github.com/jimbeaudoin/ember-simple-auth-devise-example .
现在我的身份验证根本不起作用,因为 authenticate_with_http_token 总是空的,我找不到任何问题。你有好主意吗 ?谢谢。

版本:

Ember: 2.1.0
Ember Simple Auth: 1.0.1
Rails: 4.2.4
Devise: 3.5.2
No Ember data

Rails:

class Api::SessionsController < Devise::SessionsController
  skip_before_action :authenticate_user_from_token!
  skip_before_action :verify_authenticity_token

  def create
    respond_to do |format|
      format.html { super }
      format.json do
        self.resource = warden.authenticate!(auth_options)
        sign_in(resource_name, resource)
        data = {
          token: self.resource.authentication_token,
          email: self.resource.email
        }
        render json: data, status: 201
      end
    end
  end
end


class Api::BaseController < ApplicationController
  respond_to :json
  before_action :authenticate_user_from_token!

  # Enter the normal Devise authentication path,
  # using the token authenticated user if available
  before_action :authenticate_user!

  private

  def authenticate_user_from_token!
    authenticate_with_http_token do |token, options|
      user_email = options[:email].presence
      user = user_email && User.unscoped.find_by_email(user_email)
      if user && Devise.secure_compare(user.authentication_token, token)
        sign_in user, store: false
      end      
    end  
  end

end

Ember:
登录控制器:

import Ember from 'ember';

export default Ember.Controller.extend({
  session: Ember.inject.service('session'),

  actions: {
    authenticate() {
      let { identification, password } = this.getProperties('identification', 'password');
      this.get('session').authenticate('authenticator:devise', identification, password).catch((reason) => {
        this.set('errorMessage', reason.error);
      });
    }
  }
})

ember 型号:

import Ember from 'ember';
import PromiseArray from './promise-array';
import PromiseObject from './promise-object';

var Account = Ember.Object.extend({
  ...
})

Account.reopenClass({
  _find() {
    return $.get("/api/account.json").then(obj => {
      return this.create(obj.user);
    })
  },

  find() {
    return PromiseObject.create({promise: this._find()});
  }
})

export default Account;

登录路线后:

import Ember from 'ember';
import Account from '../models/account';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';

export default Ember.Route.extend(AuthenticatedRouteMixin, {
  model: function() {
    return Account.find()
  }
})

我认为您遇到的问题是初始登录请求后的请求授权?您是否在 Ember 应用中的任何位置授权传出请求?