简体   繁体   English

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

[英]Ember Simple Auth + Devise throws 405

I'm using a stack consisting of Rails with Grape (for API stuff) and Devise (for user stuff), and Ember with Ember CLI and Ember Simple Auth. 我使用的堆栈由Rails和Grape组成(用于API的东西)和Devise(对于用户的东西),以及Ember和Ember CLI和Ember Simple Auth。 I want to implement authorization using the DeviseAuthenticator exposed by Simple Auth. 我想使用由简单身份验证公开的DeviseAuthenticator来实现授权。 My login controller looks like this: 我的登录控制器如下所示:

// 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)
      })
    }
  }
})

and my Devise authenticator setup: 和我的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/']
})

For development purposes, I've commented out the error! "401 Unauthorized", 401 unless authenticated 出于开发目的,我已注释掉该error! "401 Unauthorized", 401 unless authenticated error! "401 Unauthorized", 401 unless authenticated part in my Grape config (that's another problem though) just to see if it even works, but it throws this: 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)

I have no idea what to do, and as such would appreciate some help. 我不知道该怎么办,因此将不胜感激。 If I can post more code from other files, I'd be happy to, just tell me. 如果我可以从其他文件中发布更多代码,请告诉我。

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

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

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