diff --git a/js/app.js b/js/app.js index 6e04297..f045243 100644 --- a/js/app.js +++ b/js/app.js @@ -8,13 +8,13 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider $urlRouterProvider.otherwise('/splash-page'); $stateProvider .state('splash-page', { - data: { requiresLogin: false }, + data: { requiresLogin: false, session: null }, url: '/splash-page', templateUrl: '/templates/splash-page.html', controller: 'loginCtrl as vm' }) .state('app',{ - data: { requiresLogin: true }, + data: { requiresLogin: true, session: null }, url: '/', controller: 'loginCtrl as vm', views: { @@ -112,11 +112,12 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider }); }]); -app.run(['$rootScope', '$state', 'Auth', function($rootScope, $state, Auth) { +app.run(['$rootScope', '$state', 'Auth', '$location', function($rootScope, $state, Auth, $location) { + console.log('$location:', $location.search()); $rootScope.urlArray = []; - $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { var requiresLogin = toState.data.requiresLogin; + toState.data.session = $location.search(); $rootScope.redirectedURL = toState.url; $rootScope.urlArray.push($rootScope.redirectedURL); if ($rootScope.urlArray.length > 1) { @@ -126,7 +127,11 @@ app.run(['$rootScope', '$state', 'Auth', function($rootScope, $state, Auth) { if (requiresLogin && !Auth.isLoggedIn()) { event.preventDefault(); + console.log('asdfasdfasdfasdfasdfasdfasdfasdf', toState); $state.go('splash-page', { 'toState': toState.name }); + } else { + // Auth.get(Auth.session); + } }); }]); diff --git a/js/controllers/login-controller.js b/js/controllers/login-controller.js index bcca67c..8d01bd3 100644 --- a/js/controllers/login-controller.js +++ b/js/controllers/login-controller.js @@ -1,6 +1,6 @@ app.controller('loginCtrl', [ - '$scope', '$timeout', 'Auth', '$location', 'localStorageService', '$rootScope', 'azp@oauth3.org' -, function ($scope, $timeout, Auth, $location, localStorageService, $rootScope, Oauth3) { + '$scope', '$timeout', 'Auth', '$location', 'localStorageService', '$rootScope', 'azp@oauth3.org', '$stateParams' +, function ($scope, $timeout, Auth, $location, localStorageService, $rootScope, Oauth3, $stateParams) { var vm = this; diff --git a/templates/splash-page.html b/templates/splash-page.html index b511195..95e7e7f 100644 --- a/templates/splash-page.html +++ b/templates/splash-page.html @@ -1,7 +1,7 @@

Sign in

- +
Resume with {{ profile.email }}