Mixins in Ember FW
Mixins are a way to define certain properties to other classes. For more informations on Mixins, see Ember API docs. Most of our mixins defined in this addon are used to use some common logic to make the app work with Group Control. Most often dealing with various routes and whether the user actually has permissions to access the route, though there are a few other mixins dealing with authentication as well.
Route Mixins
There are several route mixins, which are used automatically added for you depending upon whether you use the AuthRoute
or RestrictedRoute
, as documented here. These mixins are helpful to know what they do, but are not something that you need to implement at all (so long as you extend one of the two built in routes). Mixins used by both routes are the AuthCheckMixin, and the PermissionsMixin. The RestrictedRouteMixin and AuthRouteMixin are used only for the routes which are named after then respectively.
There are a couple of other route mixins which are implemented in every app, and they have specific functions. Most likely, since these are implemented automatically when an app is generated, your app already has incorporated these mixins, but if not you will need to add them:
- IndexRouteMixin is designed to go on the
index.js
route, and it handles redirecting tomainRoute
(set in the index route as well) if the user has roles in the app, or redirecting to the No Permissions page if they do not. Because of this, theindex
route must be separate from whatever your main route that the app loads into by default (otherwise the No Permissions page will not display properly). - DepartmentTransitionMixin is designed to go in the
application.js
route, and it allows for passing in a query parameter ofsetdept
, which will change the users department (if they have access to that department) before loading the contents of the page. Thissetdept
query parameter can be added to any url as a query parameter, and it will handle it correctly. This can be especially useful for email links to specific data (because if you aren't in the proper department you can't access that data).
Other Mixins
There two other mixins defined by Ember FW GC. One is the ApplicationControllerMixin, which is designed to add in the re-login functionality for the re-login modal. The other is the deprecated AuthComponentMixin, which is used by a few of our deprecated components.