fixing tokens and logins

This commit is contained in:
Jon Lambson 2017-10-31 12:24:52 -06:00
parent b1e29b8d8d
commit b97bf25788
5 changed files with 21 additions and 9 deletions

View File

@ -156,25 +156,34 @@ app.config([
app.run(['$rootScope', '$state', 'Auth', '$location', function($rootScope, $state, Auth, $location) { app.run(['$rootScope', '$state', 'Auth', '$location', function($rootScope, $state, Auth, $location) {
$rootScope.urlArray = []; $rootScope.urlArray = [];
$rootScope.urlCrumbs = [];
$rootScope.urlInfo = { $rootScope.urlInfo = {
url: $location.$$url, url: $location.$$url,
path: $location.$$path, path: $location.$$path,
params: $location.$$search params: $location.$$search
}; };
debugger;
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
var requiresLogin = toState.data.requiresLogin; var requiresLogin = toState.data.requiresLogin;
// toState.data.session = $location.search(); toState.data.session = $location.search();
$rootScope.redirectedURL = toState.url; $rootScope.redirectedURL = toState.url;
var query = $location.search(); var query = $location.search();
$rootScope.urlArray.push($rootScope.redirectedURL); $rootScope.urlArray.push($rootScope.redirectedURL);
$rootScope.urlCrumbs.push($rootScope.urlInfo);
debugger;
if (requiresLogin && !Auth.isLoggedIn()) { if (requiresLogin && !Auth.isLoggedIn()) {
event.preventDefault(); event.preventDefault();
if (!angular.equals(toState.data.session, {})) { if (!angular.equals(toState.data.session, {})) {
toState.data.session.token = OAUTH3.jwt.decode(query.access_token); debugger;
toState.data.session.refresh = OAUTH3.jwt.decode(query.refresh_token); if (toState.data.session.refresh !== undefined) {
Auth.add(query); toState.data.session.token = OAUTH3.jwt.decode(query.access_token);
$state.go('app.' + $rootScope.redirectedURL); 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 { } else {
$state.go('splash-page', { 'toState': toState.name }); $state.go('splash-page', { 'toState': toState.name });
} }

View File

@ -110,7 +110,7 @@ app.controller('loginCtrl', [
$location.path('/home'); $location.path('/home');
} else { } else {
debugger; debugger;
$location.path('/' + $rootScope.redirectedURL); $location.path('/' + $rootScope.urlInfo.url);
} }
}, function (err) { }, function (err) {
console.error('auth error'); console.error('auth error');

View File

@ -189,8 +189,9 @@ app.controller('websiteCtrl', [
vm.shareInit = function () { vm.shareInit = function () {
if ($rootScope.urlInfo.params.token !== undefined) { if ($rootScope.urlInfo.params.token !== undefined) {
console.log('FISH STICKS', $rootScope.urlInfo); console.log('FISH STICKS', $rootScope.urlInfo);
vm.Shares.inviteToken = $rootScope.urlInfo.params.token;
var result = { data: { info: true } }; var result = { data: { info: true } };
var msg = "You can only view inside the "; var msg = "You have a new share.";
vm.buildNotification(result, msg); vm.buildNotification(result, msg);
// debugger; // debugger;
} }

View File

@ -22,6 +22,8 @@ app.factory('Auth', [
return Auth.sessions || false; return Auth.sessions || false;
} }
, add: function (session) { , add: function (session) {
console.log($rootScope);
debugger;
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;

View File

@ -117,7 +117,7 @@
<li class="cards__item" ng-repeat="r in vm.sites"> <li class="cards__item" ng-repeat="r in vm.sites">
<div class="card"> <div class="card">
<div class="card__image card__image--fence avoid-clicks"> <div class="card__image card__image--fence avoid-clicks">
<iframe src="{{ r.urlSafeDomain }}" width="350" height="350"></iframe> <iframe ng-src="{{ r.urlSafeDomain }}" width="350" height="350"></iframe>
</div> </div>
<div class="card__content"> <div class="card__content">
<div class="card__title text-center"><a ng-href="https://{{ r.domain }}" target="_blank" ng-bind="r.domain">example.com</a></div> <div class="card__title text-center"><a ng-href="https://{{ r.domain }}" target="_blank" ng-bind="r.domain">example.com</a></div>