Before using ember-cli-simple-auth I had this initializer:
Ember.Application.initializer({
name: 'authentication',
initialize: function(container, application) {
container.register('authenticator:api', Oauth2Authenticator);
Ember.SimpleAuth.setup(container, application, {
authorizerFactory: 'ember-simple-auth-authorizer:oauth2-bearer',
routeAfterAuthentication: 'dashboard',
routeAfterInvalidation: 'login',
storeFactory: 'ember-simple-auth-session-store:local-storage'
});
}
});
How to do that now, when using imports, I've managed to get to the point:
import Oauth2Authenticator from '../services/authenticator';
export default {
name: 'authentication',
initialize: function(container, app) {
container.register('authenticator:api', Oauth2Authenticator);
// THIS PART IS NOT CLEAR, HOW TO SETUP IN AMD?
Ember.SimpleAuth.setup(container, application, {
authorizerFactory: 'ember-simple-auth-authorizer:oauth2-bearer',
routeAfterAuthentication: 'dashboard',
routeAfterInvalidation: 'login',
storeFactory: 'ember-simple-auth-session-store:local-storage'
});
// END OF CONFUSING PART
}
};
Thanks!
You must not call SimpleAuth.setup
anymore as it's private API now. If you're using Ember CLI simply install the Ember CLI addon: https://github.com/simplabs/ember-cli-simple-auth. If you're using EAK (in which case you should migrate to Ember CLI anyway), make sure you require the Ember Simple Auth autoloader:
require('simple-auth/ember');
Also checkout the installation instructions in the README: https://github.com/simplabs/ember-simple-auth#installation
In both cases you don't have to call SimpleAuth.setup
. If you want to register your custom authenticator, simply add an initializer that runs before the 'simple-auth' initializer:
import Oauth2Authenticator from '../services/authenticator';
export default {
name: 'authentication',
before: 'simple-auth',
initialize: function(container, app) {
container.register('authenticator:api', Oauth2Authenticator);
}
};
Configuration is now done via the global ENV
object - see API docs here: http://ember-simple-auth.simplabs.com/ember-simple-auth-api-docs.html#SimpleAuth-Configuration