From b97bf2578893db32babb3584b207d5fcd65f0f81 Mon Sep 17 00:00:00 2001 From: Jon Lambson Date: Tue, 31 Oct 2017 12:24:52 -0600 Subject: [PATCH] fixing tokens and logins --- js/app.js | 21 +++++++++++++++------ js/controllers/login-controller.js | 2 +- js/controllers/website-controller.js | 3 ++- js/services/auth-service.js | 2 ++ templates/website.html | 2 +- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/js/app.js b/js/app.js index 4555a2c..c5151cb 100644 --- a/js/app.js +++ b/js/app.js @@ -156,25 +156,34 @@ app.config([ app.run(['$rootScope', '$state', 'Auth', '$location', function($rootScope, $state, Auth, $location) { $rootScope.urlArray = []; + $rootScope.urlCrumbs = []; $rootScope.urlInfo = { url: $location.$$url, path: $location.$$path, params: $location.$$search }; + debugger; $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { var requiresLogin = toState.data.requiresLogin; - // toState.data.session = $location.search(); + toState.data.session = $location.search(); $rootScope.redirectedURL = toState.url; var query = $location.search(); $rootScope.urlArray.push($rootScope.redirectedURL); - + $rootScope.urlCrumbs.push($rootScope.urlInfo); + debugger; if (requiresLogin && !Auth.isLoggedIn()) { event.preventDefault(); if (!angular.equals(toState.data.session, {})) { - toState.data.session.token = OAUTH3.jwt.decode(query.access_token); - toState.data.session.refresh = OAUTH3.jwt.decode(query.refresh_token); - Auth.add(query); - $state.go('app.' + $rootScope.redirectedURL); + debugger; + if (toState.data.session.refresh !== undefined) { + toState.data.session.token = OAUTH3.jwt.decode(query.access_token); + toState.data.session.refresh = OAUTH3.jwt.decode(query.refresh_token); + Auth.add(query); + $state.go('app.' + $rootScope.redirectedURL); + } else { + $state.go('splash-page', { 'toState': toState.name }); + debugger; + } } else { $state.go('splash-page', { 'toState': toState.name }); } diff --git a/js/controllers/login-controller.js b/js/controllers/login-controller.js index 3fd0d41..6289cc1 100644 --- a/js/controllers/login-controller.js +++ b/js/controllers/login-controller.js @@ -110,7 +110,7 @@ app.controller('loginCtrl', [ $location.path('/home'); } else { debugger; - $location.path('/' + $rootScope.redirectedURL); + $location.path('/' + $rootScope.urlInfo.url); } }, function (err) { console.error('auth error'); diff --git a/js/controllers/website-controller.js b/js/controllers/website-controller.js index 5cae9b8..fd12c77 100644 --- a/js/controllers/website-controller.js +++ b/js/controllers/website-controller.js @@ -189,8 +189,9 @@ app.controller('websiteCtrl', [ vm.shareInit = function () { if ($rootScope.urlInfo.params.token !== undefined) { console.log('FISH STICKS', $rootScope.urlInfo); + vm.Shares.inviteToken = $rootScope.urlInfo.params.token; var result = { data: { info: true } }; - var msg = "You can only view inside the "; + var msg = "You have a new share."; vm.buildNotification(result, msg); // debugger; } diff --git a/js/services/auth-service.js b/js/services/auth-service.js index 7331351..095e067 100644 --- a/js/services/auth-service.js +++ b/js/services/auth-service.js @@ -22,6 +22,8 @@ app.factory('Auth', [ return Auth.sessions || false; } , add: function (session) { + console.log($rootScope); + debugger; var obj = JSON.parse(localStorage.getItem(dapSessions) || 'null') || {}; var dapName = 'dap-' + session.subject + '|' + session.issuer; diff --git a/templates/website.html b/templates/website.html index 9166f29..74c3644 100644 --- a/templates/website.html +++ b/templates/website.html @@ -117,7 +117,7 @@