[英]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.