How to use a custom authorizer and custom authenticator for ember simple-auth in ember cli

南笙酒味 提交于 2020-01-12 05:39:51

问题


I don't understand how I'm supposed to include my custom authenticator and custom authorizor with ember cli.

Where to put it and what to include and how to do it. The cli example for simple-auth provided unfortunately does not cover custom authorizer and authenticator.

The build is successfully, but when running it in the browser, I get the error

TypeError: SimpleAuth.Authenticators is undefined

I'm aware that I'm doing something wrong, but could you please guide me or point me to the right documentation on how to do this, I can't find anything :( My initializer looks like this:

import Ember from 'ember';
import CustomAuthenticator from "../models/customauthenticator";

export default {
  name : 'authentication',
  before : 'simple-auth',
  initialize : function(container) {
    container.register('authenticator:custom', CustomAuthenticator);
    //container.register('authorizer:custom', CustomAuthorizer);
  }
};

My authenticator looks like this

import Ember from "ember";
import App from '../app';
import SimpleAuth from "simple-auth/authenticators/base";

App.CustomAuthenticator = SimpleAuth.Authenticators.Base.extend({
  tokenEndpoint: '/api/RestUser.php/users/core/access/',

  restore: function(data) {
    [...]
  },
  authenticate: function(credentials) {
    [...]
  },
  invalidate: function() {
    [...]
  }
});

What am I missing? Thanks in advance!


回答1:


Change that to:

...
import Base from "simple-auth/authenticators/base";

export default Base.extend({
...


来源:https://stackoverflow.com/questions/26526960/how-to-use-a-custom-authorizer-and-custom-authenticator-for-ember-simple-auth-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!