Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function () {
- 'use strict';
- angular
- .module('main', [
- 'ui.router',
- 'ui.bootstrap',
- 'ngMask',
- 'ngCookies',
- 'ngRoute',
- 'ngDialog',
- 'ngAnimate',
- 'cr.acl',
- 'ui-notification',
- 'ngFlash',
- 'textAngular',
- 'flow',
- 'angular-loading-bar',
- 'hl.sticky',
- 'about',
- 'speakers',
- 'schedule',
- 'partner',
- 'register',
- 'admin',
- 'config'
- ])
- .config(config)
- .run(run);
- config.$inject = ['$stateProvider', '$urlRouterProvider', 'cfpLoadingBarProvider', 'NotificationProvider'];
- function config($stateProvider, $urlRouterProvider, cfpLoadingBarProvider, NotificationProvider) {
- cfpLoadingBarProvider.includeSpinner = false;
- NotificationProvider.setOptions({
- startTop: 25,
- startRight: 25,
- verticalSpacing: 20,
- horizontalSpacing: 20,
- positionX: 'right',
- positionY: 'top'
- });
- $urlRouterProvider.otherwise(function ($injector) {
- var $state = $injector.get("$state");
- var $location = $injector.get("$location");
- var crAcl = $injector.get("crAcl");
- var state = "";
- switch (crAcl.getRole()) {
- case 'ROLE_ADMIN':
- state = 'admin.pages';
- break;
- default : state = 'main.about';
- }
- if (state) $state.go(state);
- else $location.path('/');
- });
- $stateProvider
- .state('main', {
- url: '/',
- abstract: true,
- templateUrl: '../views/main.html',
- controller: 'GlobalCtrl as vm',
- data: {
- is_granted: ['ROLE_GUEST']
- }
- })
- .state('blog', {
- url: '/blog',
- templateUrl: '../blog.html'
- })
- .state('auth', {
- url: '/login',
- templateUrl: '../views/auth/login.html',
- controller: 'AuthCtrl as auth',
- onEnter: ['AuthService', 'crAcl', function(AuthService, crAcl) {
- AuthService.clearCredentials();
- crAcl.setRole();
- }],
- data: {
- is_granted: ['ROLE_GUEST']
- }
- });
- }
- run.$inject = ['$rootScope', '$cookieStore', '$state', 'crAcl', '$window'];
- function run($rootScope, $cookieStore, $state, crAcl, $window) {
- // keep user logged in after page refresh
- $rootScope.globals = $cookieStore.get('globals') || {};
- crAcl
- .setInheritanceRoles({
- 'ROLE_ADMIN': ['ROLE_ADMIN', 'ROLE_GUEST'],
- 'ROLE_GUEST': ['ROLE_GUEST']
- });
- crAcl
- .setRedirect('auth');
- if ($rootScope.globals.currentUser) {
- crAcl.setRole('ROLE_ADMIN');
- }
- else {
- crAcl.setRole();
- }
- $rootScope.$on('$stateChangeSuccess', function (event, current, previous) {
- $window.document.title = current.title ? current.title + ' - ANGULAR SUMMIT' : 'ANGULAR SUMMIT';
- });
- }
- })();
Add Comment
Please, Sign In to add comment