fixing login
This commit is contained in:
parent
de8798f01b
commit
fa5568d9cb
88
index.html
88
index.html
|
@ -1,49 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html ng-app="launchpad" ng-strict>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Launch-pad</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="/css/lib/bootstrap/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="/css/styles.css">
|
||||
</head>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Launch-pad</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="/css/lib/bootstrap/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="/css/styles.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div ui-view class="splash-page" ng-controller="SignInController as vm"></div>
|
||||
<div class="search-bar" ui-view="header"></div>
|
||||
<div class="container main-content">
|
||||
<div class="menu-container" ui-view="menu"></div>
|
||||
<div class="main-content-container" ui-view="content"></div>
|
||||
<div class="notifications-container" ui-view="notifications"></div>
|
||||
</div>
|
||||
<body>
|
||||
<div ui-view class="splash-page" ng-controller="SignInController as vm"></div>
|
||||
<div class="search-bar" ui-view="header"></div>
|
||||
<div class="container main-content">
|
||||
<div class="menu-container" ui-view="menu"></div>
|
||||
<div class="main-content-container" ui-view="content"></div>
|
||||
<div class="notifications-container" ui-view="notifications"></div>
|
||||
</div>
|
||||
|
||||
<!-- JQuery -->
|
||||
<script src="/js/lib/jquery/jquery-2.2.0.min.js" charset="utf-8"></script>
|
||||
<!-- Bootstrap -->
|
||||
<script src="/js/lib/bootstrap/bootstrap.min.js" charset="utf-8"></script>
|
||||
<!-- Lodash -->
|
||||
<script src="/js/lib/lodash/lodash.min.js" charset="utf-8"></script>
|
||||
<script src="/js/lib/lodash/lodash.underscore.min.js" charset="utf-8"></script>
|
||||
<!-- Angular Modules -->
|
||||
<script src="/js/lib/angular/angular.min.js" charset="utf-8"></script>
|
||||
<script src="/js/lib/angular/angular-local-storage.js" charset="utf-8"></script>
|
||||
<script src="/js/lib/angular/angular-ui-router.min.js" charset="utf-8"></script>
|
||||
<!-- Core Files -->
|
||||
<script src="/js/app.js" charset="utf-8"></script>
|
||||
<!-- Services -->
|
||||
<script src="/js/services/contacts.js" charset="utf-8"></script>
|
||||
<script src="/js/services/auth.js" charset="utf-8"></script>
|
||||
<!-- Controllers -->
|
||||
<script src="/js/controllers/signInController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/homeController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/boltController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/filesController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/contactController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/contactDetailController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/musicController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/websiteController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/dnsController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/emailController.js" charset="utf-8"></script>
|
||||
</body>
|
||||
<!-- JQuery -->
|
||||
<script src="/js/lib/jquery/jquery-2.2.0.min.js" charset="utf-8"></script>
|
||||
<!-- Bootstrap -->
|
||||
<script src="/js/lib/bootstrap/bootstrap.min.js" charset="utf-8"></script>
|
||||
<!-- Lodash -->
|
||||
<script src="/js/lib/lodash/lodash.min.js" charset="utf-8"></script>
|
||||
<script src="/js/lib/lodash/lodash.underscore.min.js" charset="utf-8"></script>
|
||||
<!-- Angular Modules -->
|
||||
<script src="/js/lib/angular/angular.min.js" charset="utf-8"></script>
|
||||
<script src="/js/lib/angular/angular-local-storage.js" charset="utf-8"></script>
|
||||
<script src="/js/lib/angular/angular-ui-router.min.js" charset="utf-8"></script>
|
||||
<!-- Core Files -->
|
||||
<script src="/js/app.js" charset="utf-8"></script>
|
||||
<!-- Services -->
|
||||
<script src="/js/services/contacts.js" charset="utf-8"></script>
|
||||
<script src="/js/services/auth.js" charset="utf-8"></script>
|
||||
<!-- Controllers -->
|
||||
<script src="/js/controllers/signInController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/homeController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/boltController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/filesController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/contactController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/contactDetailController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/musicController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/websiteController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/dnsController.js" charset="utf-8"></script>
|
||||
<script src="/js/controllers/emailController.js" charset="utf-8"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
278
js/app.js
278
js/app.js
|
@ -1,142 +1,148 @@
|
|||
var app = angular.module('launchpad', ['ui.router', 'LocalStorageModule']);
|
||||
|
||||
app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider', function($stateProvider, $urlRouterProvider, localStorageServiceProvider){
|
||||
localStorageServiceProvider.setPrefix('launchpad').setStorageType('sessionStorage');
|
||||
localStorageServiceProvider.setPrefix('launchpad').setStorageType('sessionStorage');
|
||||
|
||||
$urlRouterProvider.otherwise('/splash-page');
|
||||
$urlRouterProvider.otherwise('/splash-page');
|
||||
|
||||
$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',
|
||||
controller: 'HomeController',
|
||||
controllerAs: 'vm'
|
||||
},
|
||||
'menu': {
|
||||
templateUrl: '/templates/partials/menu.html'
|
||||
},
|
||||
'content': {
|
||||
templateUrl: '/templates/home.html'
|
||||
},
|
||||
'notifications': {
|
||||
templateUrl: '/templates/partials/notifications.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.home', {
|
||||
url: 'home',
|
||||
data: {
|
||||
'requiresLogin': true
|
||||
},
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/home.html',
|
||||
controller: 'HomeController',
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.bolt', {
|
||||
url: 'bolt',
|
||||
data: {
|
||||
'requiresLogin': true
|
||||
},
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/bolt.html',
|
||||
controller: 'BoltController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.files', {
|
||||
url: 'files',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/files.html',
|
||||
controller: 'FilesController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.contacts', {
|
||||
url: 'contacts',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/contacts.html',
|
||||
controller: 'ContactController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.contacts.detail', {
|
||||
url: '/:id',
|
||||
/*
|
||||
templateUrl: 'templates/partials/subscriber-detail.html',
|
||||
controller: 'SubscriberDetailController'
|
||||
*/
|
||||
views: {
|
||||
'detail@app.contacts': {
|
||||
templateUrl: 'templates/partials/contact-detail.html',
|
||||
controller: 'ContactDetailController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.music', {
|
||||
url: 'music',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/music.html',
|
||||
controller: 'MusicController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.email', {
|
||||
url: 'email',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/email.html',
|
||||
controller: 'EmailController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.website', {
|
||||
url: 'website',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/website.html',
|
||||
controller: 'WebsiteController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.dns', {
|
||||
url: 'dns',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/dns.html',
|
||||
controller: 'DnsController'
|
||||
}
|
||||
}
|
||||
});
|
||||
}])
|
||||
.run(['$rootScope', '$state', 'Auth', function($rootScope, $state, Auth) {
|
||||
|
||||
// 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});
|
||||
// }
|
||||
});
|
||||
|
||||
$stateProvider
|
||||
.state('splash-page', {
|
||||
url: '/splash-page',
|
||||
templateUrl: '/templates/splash-page.html',
|
||||
})
|
||||
.state('app',{
|
||||
url: '/launchpad-',
|
||||
views: {
|
||||
'header': {
|
||||
templateUrl: '/templates/partials/header.html',
|
||||
controller: 'HomeController',
|
||||
controllerAs: 'vm'
|
||||
},
|
||||
'menu': {
|
||||
templateUrl: '/templates/partials/menu.html'
|
||||
},
|
||||
'content': {
|
||||
templateUrl: '/templates/home.html'
|
||||
},
|
||||
'notifications': {
|
||||
templateUrl: '/templates/partials/notifications.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.home', {
|
||||
url: 'home',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/home.html',
|
||||
controller: 'HomeController',
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.sign-in', {
|
||||
url: 'sign-in',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/sign-in.html',
|
||||
controller: 'SignInController',
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.bolt', {
|
||||
url: 'bolt',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/bolt.html',
|
||||
controller: 'BoltController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.files', {
|
||||
url: 'files',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/files.html',
|
||||
controller: 'FilesController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.contacts', {
|
||||
url: 'contacts',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/contacts.html',
|
||||
controller: 'ContactController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.contacts.detail', {
|
||||
url: '/:id',
|
||||
/*
|
||||
templateUrl: 'templates/partials/subscriber-detail.html',
|
||||
controller: 'SubscriberDetailController'
|
||||
*/
|
||||
views: {
|
||||
'detail@app.contacts': {
|
||||
templateUrl: 'templates/partials/contact-detail.html',
|
||||
controller: 'ContactDetailController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.music', {
|
||||
url: 'music',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/music.html',
|
||||
controller: 'MusicController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.email', {
|
||||
url: 'email',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/email.html',
|
||||
controller: 'EmailController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.website', {
|
||||
url: 'website',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/website.html',
|
||||
controller: 'WebsiteController'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('app.dns', {
|
||||
url: 'dns',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: 'templates/dns.html',
|
||||
controller: 'DnsController'
|
||||
}
|
||||
}
|
||||
});
|
||||
}]);
|
||||
|
||||
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');
|
||||
}
|
||||
});
|
||||
}]);
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
app.controller('HomeController', ['$scope', 'Auth', 'localStorageService', '$location', function ($scope, Auth, localStorageService, $location) {
|
||||
var vm = this;
|
||||
var vm = this;
|
||||
|
||||
vm.signOut = function () {
|
||||
localStorageService.remove('userAuth');
|
||||
$location.path('/splash-page');
|
||||
}
|
||||
vm.signOut = function () {
|
||||
localStorageService.remove('userAuth');
|
||||
$location.path('/splash-page');
|
||||
}
|
||||
|
||||
function userAuth() {
|
||||
return JSON.parse(localStorageService.get('userAuth'));
|
||||
}
|
||||
function userAuth() {
|
||||
return JSON.parse(localStorageService.get('userAuth'));
|
||||
}
|
||||
|
||||
$scope.$watch(Auth.isLoggedIn, function (value, oldValue) {
|
||||
if (!value && !oldValue) {
|
||||
$location.path('/splash-page');
|
||||
}
|
||||
}, true);
|
||||
$scope.$watch(Auth.isLoggedIn, function (value, oldValue) {
|
||||
if (!value && !oldValue) {
|
||||
$location.path('/splash-page');
|
||||
}
|
||||
}, true);
|
||||
|
||||
}]);
|
||||
|
|
|
@ -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,12 +1,12 @@
|
|||
app.factory('Auth', ['localStorageService', function(localStorageService){
|
||||
var user;
|
||||
return{
|
||||
setUser : function(currentUser){
|
||||
user = currentUser;
|
||||
},
|
||||
isLoggedIn : function(){
|
||||
user = JSON.parse(localStorageService.get('userAuth'));
|
||||
return (user) ? user : false;
|
||||
}
|
||||
};
|
||||
var user;
|
||||
return{
|
||||
setUser : function(currentUser){
|
||||
user = currentUser;
|
||||
},
|
||||
isLoggedIn : function(){
|
||||
user = JSON.parse(localStorageService.get('userAuth'));
|
||||
return (user) ? user : false;
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
<ul class="dropdown-menu">
|
||||
<li><a href="feed.html" target="_blank">Preview My Public Site</a></li>
|
||||
<li><a>Account Settings</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a>Switch User</a></li>
|
||||
<li ng-click="vm.signOut()"><a>Logout</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a>Switch User</a></li>
|
||||
<li ng-click="vm.signOut()"><a>Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -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