7
votes

I am implementing ember-engine in my application. I am using ember-simple-auth addon for authentication. It works well with main application routes.

I extend the protected routes with mixin provided by addon.

// app/routes/protected.js
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';

export default Ember.Route.extend(AuthenticatedRouteMixin);

Now I have created a users engine. which has the userlist and some other stuff. I want user to access this page only if he is authenticated. In main app routes I can extend the route with mixin and it will redirect to login route if the user is not authenticated. But same things does not work with users engine routes.

Any idea about how to implement Ember-simple-auth with Ember-engines ?

Reference : -

Ember engines - https://github.com/ember-engines/ember-engines

Ember simple auth - https://github.com/simplabs/ember-simple-auth

EDIT-

//lib/users-engine/routes/edit.js
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin);

I tried to extend the engines route as above.

1
Never worked with engines (btw, why did you decided to use them?) but looking on description of ember-engines addon, I guess that you need to support ember-simple-auth in your engine (i.e add it to engine's dependencies and modify engine's routes).Gennady Dogaev
@GennadyDogaev I tried to extend the engines route with ember-simple-auth authentication mixin. But that is not working.murli2308
Can you show us where you extend Engine and import your dependencies? (e.g.): export default Engine.extend({IAMZERG
@IAMZERG updated the questionmurli2308

1 Answers

1
votes

Your engine needs to define dependencies it needs the main app to provide. In your case, you'll need the simple auth service, see Declaring Dependencies for more details.

https://github.com/ember-engines/ember-engines#declaring-dependencies

Note: the mixins that simple auth uses may not work out of the box with this setup (but I think they should). On my phone atm, can look into it later if needed.