问题
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