Skip to content

Instantly share code, notes, and snippets.

@jongravois
Forked from sonicparke/app.js
Last active August 29, 2015 14:15
Show Gist options
  • Save jongravois/22e6c39960655c383cd3 to your computer and use it in GitHub Desktop.
Save jongravois/22e6c39960655c383cd3 to your computer and use it in GitHub Desktop.
(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