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
|
||||
.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});
|
||||
// }
|
||||
});
|
||||
|
||||
}]);
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
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();
|
||||
}]);
|
||||
|
|
|
@ -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…
Reference in New Issue