繁体   English   中英

灰烬简单身份验证+设计抛出405

[英]Ember Simple Auth + Devise throws 405

我使用的堆栈由Rails和Grape组成(用于API的东西)和Devise(对于用户的东西),以及Ember和Ember CLI和Ember Simple Auth。 我想使用由简单身份验证公开的DeviseAuthenticator来实现授权。 我的登录控制器如下所示:

// app/controllers/login.js

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 => {
        console.log(reason.error || reason)
      })
    }
  }
})

和我的Devise身份验证器设置:

// app/authenticators/devise.js

import Devise from 'ember-simple-auth/authenticators/devise'

export default Devise.extend({
  serverTokenEndpoint: 'http://localhost:4200/api/v1/users/sign_in',
  resourceName: 'user',
  crossOriginWhiteList: ['http://localhost:4200/']
})

出于开发目的,我已注释掉该error! "401 Unauthorized", 401 unless authenticated error! "401 Unauthorized", 401 unless authenticated在我的Grape配置中经过error! "401 Unauthorized", 401 unless authenticated部分(尽管这是另一个问题),只是为了查看它是否仍然有效,但是会抛出以下错误:

POST http://localhost:4200/api/v1/users/sign_in 405 (Method Not Allowed)

我不知道该怎么办,因此将不胜感激。 如果我可以从其他文件中发布更多代码,请告诉我。

发现我的设计路线位于/users/sign_in ,而不是/api/v1/users/sign_in

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM