-
-
Save jongravois/22e6c39960655c383cd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
//'use strict'; | |
angular.module('app', [ | |
/* Shared modules */ | |
'app.core', | |
/* Feature areas */ | |
'app.layout' | |
]).config(config); | |
// TODO: Figure out how to move routes to feature folders. Keep getting $stateProvider injection error | |
config.$inject = ['$stateProvider', '$httpProvider', '$tooltipProvider', '$urlRouterProvider', '$locationProvider']; | |
/* @ngInject */ | |
function config($stateProvider, $httpProvider, $tooltipProvider, $urlRouterProvider) { | |
delete $httpProvider.defaults.headers.common['X-Requested-With']; | |
$httpProvider.interceptors.push('AuthInterceptor'); | |
$stateProvider | |
.state('applist', { | |
url: '/applist', | |
templateUrl: 'app/applist/applist.html', | |
controller: 'AppList', | |
controllerAs: 'vm', | |
resolve: { | |
validate: ['JWT', '$state', function(JWT, $state) { | |
var authenticated; | |
return JWT.getToken().then(function(res) { | |
authenticated = res; | |
if (!authenticated) { | |
$state.go('login'); | |
} | |
}); | |
}] | |
} | |
}) | |
.state('login', { | |
url: '/login', | |
templateUrl: 'app/login/login.html', | |
controller: 'Login', | |
controllerAs: 'vm', | |
resolve: { | |
validate: ['JWT', '$state', function(JWT, $state) { | |
var authenticated; | |
return JWT.getToken().then(function(res) { | |
authenticated = res; | |
if (authenticated) { | |
$state.go('applist'); | |
} | |
}); | |
}] | |
} | |
}); | |
$urlRouterProvider.otherwise('login'); | |
$tooltipProvider.options({appendToBody: true}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment