UnauthenticatedRouteMixin
import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin';
Deprecated:Call the session service's prohibitAuthentication method in the respective route's beforeModel method instead
This mixin is used to make routes accessible only if the session is
not authenticated (e.g., login and registration routes). It defines a
beforeModel
method that aborts the current transition and instead
transitions to the
routeIfAlreadyAuthenticated
if the session is authenticated.
// app/routes/login.js
import Route from '@ember/routing/route';
import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin';
export default class LoginRoute extends Route.extend(UnauthenticatedRouteMixin) {}
Methods
Checks whether the session is authenticated and if it is aborts the current transition and instead transitions to the routeIfAlreadyAuthenticated.
If beforeModel
is overridden in a route that uses this mixin, the route's
implementation must call this._super(...arguments)
so that the mixin's
beforeModel
method is actually executed.
Properties
Default: 'index'
The route to transition to if a route that implements the UnauthenticatedRouteMixin is accessed when the session is authenticated.