fixing login
This commit is contained in:
		
							parent
							
								
									de8798f01b
								
							
						
					
					
						commit
						fa5568d9cb
					
				
							
								
								
									
										50
									
								
								js/app.js
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								js/app.js
									
									
									
									
									
								
							@ -8,10 +8,20 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider
 | 
				
			|||||||
  $stateProvider
 | 
					  $stateProvider
 | 
				
			||||||
  .state('splash-page', {
 | 
					  .state('splash-page', {
 | 
				
			||||||
    url: '/splash-page',
 | 
					    url: '/splash-page',
 | 
				
			||||||
 | 
					    data: {
 | 
				
			||||||
 | 
					      'requiresLogin': false
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    params: {
 | 
				
			||||||
 | 
					      'toState': 'launchpad-home', // default state to proceed to after login
 | 
				
			||||||
 | 
					      'toParams': {}
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    templateUrl: '/templates/splash-page.html',
 | 
					    templateUrl: '/templates/splash-page.html',
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
  .state('app',{
 | 
					  .state('app',{
 | 
				
			||||||
    url: '/launchpad-',
 | 
					    url: '/launchpad-',
 | 
				
			||||||
 | 
					    data: {
 | 
				
			||||||
 | 
					      'requiresLogin': true
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    views: {
 | 
					    views: {
 | 
				
			||||||
      'header': {
 | 
					      'header': {
 | 
				
			||||||
        templateUrl: '/templates/partials/header.html',
 | 
					        templateUrl: '/templates/partials/header.html',
 | 
				
			||||||
@ -31,6 +41,9 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider
 | 
				
			|||||||
  })
 | 
					  })
 | 
				
			||||||
  .state('app.home', {
 | 
					  .state('app.home', {
 | 
				
			||||||
    url: 'home',
 | 
					    url: 'home',
 | 
				
			||||||
 | 
					    data: {
 | 
				
			||||||
 | 
					      'requiresLogin': true
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    views: {
 | 
					    views: {
 | 
				
			||||||
      'content@': {
 | 
					      'content@': {
 | 
				
			||||||
        templateUrl: 'templates/home.html',
 | 
					        templateUrl: 'templates/home.html',
 | 
				
			||||||
@ -39,18 +52,11 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
	.state('app.sign-in', {
 | 
					 | 
				
			||||||
		url: 'sign-in',
 | 
					 | 
				
			||||||
		views: {
 | 
					 | 
				
			||||||
			'content@': {
 | 
					 | 
				
			||||||
				templateUrl: 'templates/sign-in.html',
 | 
					 | 
				
			||||||
				controller: 'SignInController',
 | 
					 | 
				
			||||||
				controllerAs: 'vm'
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
  .state('app.bolt', {
 | 
					  .state('app.bolt', {
 | 
				
			||||||
    url: 'bolt',
 | 
					    url: 'bolt',
 | 
				
			||||||
 | 
					    data: {
 | 
				
			||||||
 | 
					      'requiresLogin': true
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    views: {
 | 
					    views: {
 | 
				
			||||||
      'content@': {
 | 
					      'content@': {
 | 
				
			||||||
        templateUrl: 'templates/bolt.html',
 | 
					        templateUrl: 'templates/bolt.html',
 | 
				
			||||||
@ -125,18 +131,18 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
}]);
 | 
					}])
 | 
				
			||||||
 | 
					.run(['$rootScope', '$state', 'Auth', function($rootScope, $state, Auth) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app.run(['$rootScope', '$location', 'Auth', function ($rootScope, $location, Auth) {
 | 
					  // Change title based on the `data` object in routes
 | 
				
			||||||
	$rootScope.$on('$routeChangeStart', function (event) {
 | 
					  $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
 | 
				
			||||||
		if (!Auth.isLoggedIn()) {
 | 
					    console.log('things');
 | 
				
			||||||
			console.log('DENY');
 | 
					    // var requiresLogin = toState.data.requiresLogin;
 | 
				
			||||||
			event.preventDefault();
 | 
					    //
 | 
				
			||||||
			$location.path('/login');
 | 
					    // if (requiresLogin && !LoginService.check()) {
 | 
				
			||||||
		}
 | 
					    //   event.preventDefault();
 | 
				
			||||||
		else {
 | 
					    //   $state.go('splash-page', {'toState': toState.name, 'toParams': toParams});
 | 
				
			||||||
			console.log('ALLOW');
 | 
					    // }
 | 
				
			||||||
			$location.path('/home');
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}]);
 | 
					}]);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,2 @@
 | 
				
			|||||||
app.controller('BoltController', [function($scope) {
 | 
					app.controller('BoltController', [function($scope) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
}]);
 | 
					}]);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,3 @@
 | 
				
			|||||||
app.controller('ContactController', ['$scope', function($scope) {
 | 
					app.controller('ContactController', ['$scope', 'ContactsService', function($scope, ContactsService) {
 | 
				
			||||||
	$scope.contacts = ContactsService.list();
 | 
						$scope.contacts = ContactsService.list();
 | 
				
			||||||
}]);
 | 
					}]);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,11 +0,0 @@
 | 
				
			|||||||
<form>
 | 
					 | 
				
			||||||
  <div class="form-group">
 | 
					 | 
				
			||||||
    <label for="exampleInputEmail1">Email address</label>
 | 
					 | 
				
			||||||
    <input type="email" class="form-control" placeholder="Email" ng-model="vm.userAuthEmail">
 | 
					 | 
				
			||||||
  </div>
 | 
					 | 
				
			||||||
  <div class="form-group">
 | 
					 | 
				
			||||||
    <label for="exampleInputPassword1">Password</label>
 | 
					 | 
				
			||||||
    <input type="password" class="form-control" placeholder="Password" ng-model="vm.userAuthPassword">
 | 
					 | 
				
			||||||
  </div>
 | 
					 | 
				
			||||||
  <button type="submit" class="btn btn-default" ng-click="vm.sign_in()">Submit</button>
 | 
					 | 
				
			||||||
</form>
 | 
					 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user