Carbon engines and Ember simple Auth

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

I extend secure routes with the mixin provided by the 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 mechanism for users. which has a list of users and some other things. I want the user to access this page only if he is authenticated. On the main application routes, I can extend the route using mixin and redirect it to the login if the user is not authenticated. But the same does not work with user engine routes.

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

Link: -

Amber 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 engine route as described above.

+6
source share
1 answer

Your engine needs to determine the dependencies it needs for the main application. In your case, you will need a simple auth service, see "Dependency Statement" for more details.

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

Note: mixins that use simple auth may not work out of the box with this setting (but I think they should). On my atm phone, you can learn it later if necessary.

0
source

Source: https://habr.com/ru/post/1013032/


All Articles