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) {
$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, {})) {
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 });
}

View File

@ -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');

View File

@ -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;
}

View File

@ -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;

View File

@ -117,7 +117,7 @@
<li class="cards__item" ng-repeat="r in vm.sites">
<div class="card">
<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 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>