jadjoubran/laravel5-angular-material-starter

View on GitHub
angular/run/routes.run.js

Summary

Maintainability
A
0 mins
Test Coverage
export function RoutesRun($state, $transitions, $auth) {
    'ngInject';

    let requiresAuthCriteria = {
        to: ($state) => $state.data && $state.data.auth
    };

    let redirectToLogin = ($auth) => {
        'ngInject';
        if (!$auth.isAuthenticated()) {
            return $state.target('app.login', undefined, {location: false});
        }
    };

    $transitions.onBefore(requiresAuthCriteria, redirectToLogin, {priority:10});

}