AuthenticatedRouteMixin
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
Deprecated:Call the session service's requireAuthentication method in the respective route's beforeModel method instead
This mixin is used to make routes accessible only if the session is
authenticated. It defines a beforeModel
method that aborts the current
transition and instead transitions to the
authenticationRoute if
the session is not authenticated.
// app/routes/protected.js
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
export default class ProtectedRoute extends Route.extend(AuthenticatedRouteMixin) {}
Methods
Checks whether the session is authenticated and if it is not aborts the
current transition and instead transitions to the
authenticationRoute.
If the current transition is aborted, this method will save it in the
session service's
attemptedTransition
property so that it can be retried after the session is authenticated
(see
sessionAuthenticated).
If the transition is aborted in Fastboot mode, the transition's target
URL will be saved in a ember_simple_auth-redirectTarget
cookie for use by
the browser after authentication is complete.
If beforeModel
is overridden in a route that uses this mixin, the route's
implementation must call super.beforeModel(...arguments)
so that the mixin's
beforeModel
method is actually executed.
Arguments
-
transition
:Transition
-
The transition that lead to this route
Properties
Default: 'login'
The route to transition to for authentication. The AuthenticatedRouteMixin will transition to this route when a route that implements the mixin is accessed when the route is not authenticated.