From b4c5d8a2a26bb0af5ddb05f26470262ce1581e2f Mon Sep 17 00:00:00 2001 From: Jon Lambson Date: Mon, 14 Aug 2017 12:41:55 -0600 Subject: [PATCH 1/2] think i finally fixed urls --- js/app.js | 35 ++++++------------- js/services/auth.js | 7 ++-- js/services/contacts.js | 60 ++++++++++++++++----------------- templates/website.html | 74 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 116 insertions(+), 60 deletions(-) diff --git a/js/app.js b/js/app.js index a9a1773..ea286ef 100644 --- a/js/app.js +++ b/js/app.js @@ -1,24 +1,19 @@ var app = angular.module('launchpad', ['ui.router', 'LocalStorageModule']); +var redirected = false; var redirectedURL; - +var urlArray = []; app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider', function($stateProvider, $urlRouterProvider, localStorageServiceProvider){ localStorageServiceProvider.setPrefix('launchpad').setStorageType('sessionStorage'); $urlRouterProvider.otherwise('/splash-page'); - $stateProvider .state('splash-page', { - data: { 'requiresLogin': false }, - params: { - // 'toState': 'home', - 'toParams': { - } - }, + data: { requiresLogin: false }, url: '/splash-page', templateUrl: '/templates/splash-page.html', }) .state('app',{ - data: { 'requiresLogin': true }, + data: { requiresLogin: true }, url: '/', views: { 'header': { @@ -126,27 +121,19 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider app.run(['$rootScope', '$state', 'Auth', function($rootScope, $state, Auth) { $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { - // console.log('toState', toState); - // console.log('toParams', toParams); - // console.log('fromState', fromState); - // console.log('fromParams', fromParams); - var requiresLogin = toState.data.requiresLogin; - + if (!Auth.isLoggedIn()) { redirected = true; } + // set url redirectedURL = toState.url; - - // console.log("%c" + redirectedURL, "color: yellow; font-size: 72px;"); - - if (Auth.isLoggedIn()) { - console.log('logged in'); - } else { - console.log('logged out'); + urlArray.push(redirectedURL); + if (urlArray.length > 1) { + redirectedURL = urlArray[0]; + urlArray = []; } if (requiresLogin && !Auth.isLoggedIn()) { event.preventDefault(); - $state.go('splash-page'); - // $state.go('splash-page', { 'toState': toState.name, 'toParams': toParams }); + $state.go('splash-page', { 'toState': toState.name }); } }); }]); diff --git a/js/services/auth.js b/js/services/auth.js index 3660bb5..d370bf8 100644 --- a/js/services/auth.js +++ b/js/services/auth.js @@ -1,17 +1,14 @@ -app.factory('Auth', ['localStorageService', '$location', function(localStorageService, $location) { +app.factory('Auth', ['localStorageService', '$location', '$rootScope', function(localStorageService, $location, $rootScope) { var user; - return{ setUser: function(currentUser){ user = currentUser; - - // console.log("%c" + redirectedURL, "color: red; font-size: 72px;"); - if (redirectedURL === '/splash-page') { $location.path('/home'); } else { $location.path('/' + redirectedURL); } + console.log("%c" + redirectedURL, "color: blue; font-size: 14px;"); }, isLoggedIn: function(){ user = JSON.parse(localStorageService.get('userAuth')); diff --git a/js/services/contacts.js b/js/services/contacts.js index 59bc5b0..e4b89d5 100644 --- a/js/services/contacts.js +++ b/js/services/contacts.js @@ -1,33 +1,33 @@ app.factory('ContactsService', [function(){ - var contacts = [ - { - id: 1, - name:'Jane Doe', - email: 'janedoe@test.com', - description:'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempora, repellendus facere expedita, magni cumque, voluptas vero nulla fugit enim ullam repellat earum vitae. Porro repellendus, officia quasi, alias numquam commodi.' - }, - { - id: 2, - name:'John Doe', - email: 'johndoe@gmail.com', - description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore magnam nostrum officiis dolor delectus ipsa magni error culpa, autem sit, perferendis eligendi officia quod amet perspiciatis dignissimos omnis molestias tempore.' - }, - { - id: 3, - name:'Johnny Appleseed', - email: 'jappleseed@gmail.com', - description: 'Stuff and things. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore magnam nostrum officiis dolor delectus ipsa magni error culpa, autem sit, perferendis eligendi officia quod amet perspiciatis dignissimos omnis molestias tempore.' - } - ]; + var contacts = [ + { + id: 1, + name:'Jane Doe', + email: 'janedoe@test.com', + description:'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempora, repellendus facere expedita, magni cumque, voluptas vero nulla fugit enim ullam repellat earum vitae. Porro repellendus, officia quasi, alias numquam commodi.' + }, + { + id: 2, + name:'John Doe', + email: 'johndoe@gmail.com', + description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore magnam nostrum officiis dolor delectus ipsa magni error culpa, autem sit, perferendis eligendi officia quod amet perspiciatis dignissimos omnis molestias tempore.' + }, + { + id: 3, + name:'Johnny Appleseed', + email: 'jappleseed@gmail.com', + description: 'Stuff and things. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore magnam nostrum officiis dolor delectus ipsa magni error culpa, autem sit, perferendis eligendi officia quod amet perspiciatis dignissimos omnis molestias tempore.' + } + ]; - return { - list: function(){ - return contacts; - }, - find: function(id){ - return _.find(contacts,function(contact){ - return contact.id == id; - }) - } - } + return { + list: function(){ + return contacts; + }, + find: function(id){ + return _.find(contacts,function(contact){ + return contact.id == id; + }); + } + }; }]); diff --git a/templates/website.html b/templates/website.html index 7e2278f..ae2d90c 100644 --- a/templates/website.html +++ b/templates/website.html @@ -1 +1,73 @@ -

website

+ + +
+ +
+

Create a new Website

+

Select a Domain

+
+ + . + + +
+ +
+ + +
+ +
+
+
+
+ Choose or create a public shared folder +
+
+
+
+ Who can edit and upload to this site? +
+
+ + + +
+
+

Your Websites

+ + + + + + + + + + + + + + + + + + + +
blog.jane.smith.netSites > blogs > blog.jane.smith.netjane@smith.net, jack@smith.net, friend@gmail.com
jane.smith.comSites > business > jane test sitejane@smith.net
jane.smith.eduDocuments > 2017 semester > econ class sitejane@smith.net, teacher@college.edu
+
+ +
From e704ff8d2693246617f56c02c23498fc02f979bc Mon Sep 17 00:00:00 2001 From: Jon Lambson Date: Mon, 14 Aug 2017 13:32:23 -0600 Subject: [PATCH 2/2] added website html --- assets/oauth3.org | 1 + js/services/auth.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 160000 assets/oauth3.org diff --git a/assets/oauth3.org b/assets/oauth3.org new file mode 160000 index 0000000..9a7aa32 --- /dev/null +++ b/assets/oauth3.org @@ -0,0 +1 @@ +Subproject commit 9a7aa3261f2ad97ebd436c8b1e86d168cf93023d diff --git a/js/services/auth.js b/js/services/auth.js index d370bf8..f6cbb5f 100644 --- a/js/services/auth.js +++ b/js/services/auth.js @@ -8,7 +8,6 @@ app.factory('Auth', ['localStorageService', '$location', '$rootScope', function( } else { $location.path('/' + redirectedURL); } - console.log("%c" + redirectedURL, "color: blue; font-size: 14px;"); }, isLoggedIn: function(){ user = JSON.parse(localStorageService.get('userAuth'));