This commit is contained in:
Jon Lambson 2017-08-28 12:56:53 -06:00
parent 5e1f9f9179
commit c12c644188
2 changed files with 10 additions and 10 deletions

View File

@ -118,28 +118,24 @@ app.run(['$rootScope', '$state', 'Auth', '$location', function($rootScope, $stat
var requiresLogin = toState.data.requiresLogin; var requiresLogin = toState.data.requiresLogin;
toState.data.session = $location.search(); toState.data.session = $location.search();
var urlParams = $location.search(); var urlParams = $location.search();
console.log('DUDDDDDDDEEEEEE ->', urlParams);
$rootScope.redirectedURL = toState.url; $rootScope.redirectedURL = toState.url;
$rootScope.urlArray.push($rootScope.redirectedURL); $rootScope.urlArray.push($rootScope.redirectedURL);
if ($rootScope.urlArray.length > 1) { if ($rootScope.urlArray.length > 1) {
$rootScope.redirectedURL = $rootScope.urlArray[0]; $rootScope.redirectedURL = $rootScope.urlArray[0];
$rootScope.urlArray = []; $rootScope.urlArray = [];
} }
console.log('stuff here ->', toState);
if (requiresLogin && !Auth.isLoggedIn()) { if (requiresLogin && !Auth.isLoggedIn()) {
event.preventDefault(); event.preventDefault();
console.log('stuff here ->', toState); console.log('stuff here ->', toState);
if (!angular.equals(toState.data.session, {})) { if (!angular.equals(toState.data.session, {})) {
var sess = toState.data.session.access_token; if ('access_token' in urlParams && 'refresh_token' in urlParams && 'issuer' in urlParams && 'audience' in urlParams) {
console.log('WHERE', $rootScope.redirectedURL ); Auth.add(urlParams)
// $state.go("app." + $rootScope.redirectedURL); console.log('CURRENT SESSION IS: ',Auth.sessions);
} }
if ('access_token' in urlParams && 'refresh_token' in urlParams && 'issuer' in urlParams && 'audience' in urlParams) {
Auth.add(sess)
console.log('da ');
} }
console.log('WHERE', $rootScope.redirectedURL ); console.log('WHERE', $rootScope.redirectedURL );
$state.go('splash-page', { 'toState': toState.name }); // $state.go('splash-page', { 'toState': toState.name });
} }
}); });
}]); }]);

View File

@ -22,6 +22,7 @@ app.factory('Auth', [
return Auth.sessions || false; return Auth.sessions || false;
} }
, add: function (session) { , add: function (session) {
console.log(session);
var obj = JSON.parse(localStorage.getItem(dapSessions) || 'null') || {}; var obj = JSON.parse(localStorage.getItem(dapSessions) || 'null') || {};
var dapName = 'dap-' + session.subject + '|' + session.issuer; var dapName = 'dap-' + session.subject + '|' + session.issuer;
@ -69,6 +70,8 @@ app.factory('Auth', [
return Auth.session; return Auth.session;
} }
, get: function (session) { , get: function (session) {
console.log('mother fucking');
console.log(session);
if (!session) { if (!session) {
return $q.resolve(null); return $q.resolve(null);
} }
@ -78,6 +81,7 @@ app.factory('Auth', [
} }
var name = session.token.sub + '@' + session.token.iss; var name = session.token.sub + '@' + session.token.iss;
console.log('NAME', name);
var promise; var promise;
var sess; var sess;