fixing login

This commit is contained in:
Jon Lambson 2017-08-09 12:41:43 -06:00
parent de8798f01b
commit fa5568d9cb
8 changed files with 213 additions and 219 deletions

View File

@ -8,10 +8,20 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider
$stateProvider
.state('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',
})
.state('app',{
url: '/launchpad-',
data: {
'requiresLogin': true
},
views: {
'header': {
templateUrl: '/templates/partials/header.html',
@ -31,6 +41,9 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider
})
.state('app.home', {
url: 'home',
data: {
'requiresLogin': true
},
views: {
'content@': {
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', {
url: 'bolt',
data: {
'requiresLogin': true
},
views: {
'content@': {
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) {
$rootScope.$on('$routeChangeStart', function (event) {
if (!Auth.isLoggedIn()) {
console.log('DENY');
event.preventDefault();
$location.path('/login');
}
else {
console.log('ALLOW');
$location.path('/home');
}
// Change title based on the `data` object in routes
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
console.log('things');
// var requiresLogin = toState.data.requiresLogin;
//
// if (requiresLogin && !LoginService.check()) {
// event.preventDefault();
// $state.go('splash-page', {'toState': toState.name, 'toParams': toParams});
// }
});
}]);

View File

@ -1,3 +1,2 @@
app.controller('BoltController', [function($scope) {
}]);

View File

@ -1,3 +1,3 @@
app.controller('ContactController', ['$scope', function($scope) {
app.controller('ContactController', ['$scope', 'ContactsService', function($scope, ContactsService) {
$scope.contacts = ContactsService.list();
}]);

View File

@ -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>