简体   繁体   中英

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. I want to implement authorization using the DeviseAuthenticator exposed by Simple Auth. 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:

// 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 part in my Grape config (that's another problem though) just to see if it even works, but it throws this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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