diff --git a/css/styles.css b/css/styles.css
index 467b208..3d2fc9f 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -13,3 +13,6 @@
.notifications-container {
width: 25%;
}
+.login-container {
+ top: 25vh;
+}
diff --git a/index.html b/index.html
index 956cc5f..bbced88 100644
--- a/index.html
+++ b/index.html
@@ -10,6 +10,7 @@
+
@@ -26,6 +27,7 @@
+
diff --git a/js/app.js b/js/app.js
index 6a5ef46..88638e7 100644
--- a/js/app.js
+++ b/js/app.js
@@ -1,12 +1,19 @@
'use strict';
-var app = angular.module('launchpad', ['ui.router']);
+var app = angular.module('launchpad', ['ui.router', 'LocalStorageModule']);
+
+app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider', function($stateProvider, $urlRouterProvider, localStorageServiceProvider){
+ localStorageServiceProvider.setPrefix('launchpad').setStorageType('sessionStorage');
+
+ $urlRouterProvider.otherwise('/splash-page');
-app.config(function($stateProvider, $urlRouterProvider){
- $urlRouterProvider.otherwise('/sign-in');
$stateProvider
+ .state('splash-page', {
+ url: '/splash-page',
+ templateUrl: '/templates/splash-page.html',
+ })
.state('app',{
- url: '/',
+ url: '/launchpad-',
views: {
'header': {
templateUrl: '/templates/partials/header.html',
@@ -42,11 +49,6 @@ app.config(function($stateProvider, $urlRouterProvider){
controller: 'SignInController',
controllerAs: 'vm'
}
- },
- resolve: {
- loginStatus: function(authService) {
- return authService.getUser();
- }
}
})
.state('app.bolt', {
@@ -125,4 +127,19 @@ app.config(function($stateProvider, $urlRouterProvider){
}
}
});
-});
+}]);
+
+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');
+ }
+ });
+}]);
diff --git a/js/controllers/HomeController.js b/js/controllers/HomeController.js
index a68fb34..893054c 100644
--- a/js/controllers/HomeController.js
+++ b/js/controllers/HomeController.js
@@ -1,4 +1,12 @@
-app.controller('HomeController', ['$scope', function ($scope) {
- var vm = this;
+app.controller('HomeController', ['$scope', 'Auth', 'localStorageService', '$location', function ($scope, Auth, localStorageService, $location) {
+
+ // $scope.$watch(Auth.isLoggedIn, function (value, oldValue) {
+ // if(value) {
+ // console.log("LOGGED IN!!!!");
+ // } else if (!value && !oldValue) {
+ // console.log("NOT LOGGED IN!!!");
+ // $location.path('/splash-page');
+ // }
+ // }, true);
}]);
diff --git a/js/controllers/signInController.js b/js/controllers/signInController.js
index 99a42a2..34b7876 100644
--- a/js/controllers/signInController.js
+++ b/js/controllers/signInController.js
@@ -1,17 +1,11 @@
-app.controller('SignInController', ['$scope', 'loginStatus', '$location', function ($scope, loginStatus, $location) {
+app.controller('SignInController', ['$scope', 'Auth', '$location', function ($scope, Auth, $location) {
var vm = this;
- vm.userProfile = {};
- // vm.message = loginStatus;
-
- vm.sign_in = function() {
- vm.userProfile.email = vm.userAuthEmail;
- vm.userProfile.password = vm.userAuthPassword;
- if (vm.userProfile.email === loginStatus.email && vm.userProfile.password === loginStatus.password) {
- console.log('yes!');
- $location.path('/home');
- } else {
- alert("wrong")
- }
+ vm.sign_in = function () {
+ // Ask to the server, do your job and THEN set the user
+ var user = {
+ email: "john@doe.com"
+ };
+ Auth.setUser(user); //Update the state of the user in the app
+ $location.path('/launchpad-home');
};
-
}]);
diff --git a/js/services/auth.js b/js/services/auth.js
index d8bae70..5b679a9 100644
--- a/js/services/auth.js
+++ b/js/services/auth.js
@@ -1,11 +1,12 @@
-app.factory('authService', function($q){
- return {
- getUser: function(){
- var user = {
- email: 'jane@doe.com',
- password: 'password'
- }
- return $q.when(user);
+app.factory('Auth', [function(){
+ var user;
+
+ return{
+ setUser : function(aUser){
+ user = aUser;
+ },
+ isLoggedIn : function(){
+ return(user)? user : false;
}
};
-});
+}]);
diff --git a/js/services/login.js b/js/services/login.js
new file mode 100644
index 0000000..1492cbd
--- /dev/null
+++ b/js/services/login.js
@@ -0,0 +1,3 @@
+app.factory('LoginService', [function(){
+
+}]);
diff --git a/templates/splash-page.html b/templates/splash-page.html
new file mode 100644
index 0000000..fe35e6f
--- /dev/null
+++ b/templates/splash-page.html
@@ -0,0 +1,14 @@
+