chimney (burning the logs) and combo box fixes

This commit is contained in:
aj 2017-08-25 01:40:22 +00:00
parent 0d67c0d10c
commit 419fd60f75
5 changed files with 38 additions and 59 deletions

View File

@ -5,10 +5,12 @@ app.controller('loginCtrl', [
var vm = this; var vm = this;
vm.independentIssuer = false; vm.independentIssuer = false;
vm.oauth3 = Oauth3.oauth3 = Oauth3.oauth3 || Oauth3.create(location); // TODO reuse most recent issuer?
vm.newOauth3 = Oauth3.create(location);
vm.timers = {}; vm.timers = {};
vm.defaultIssuer = 'provider.' + location.host.replace(/^cloud\./, ''); vm.defaultIssuer = 'provider.' + location.host.replace(/^cloud\./, '');
vm.Auth = Auth;
vm.session = Auth.session; vm.session = Auth.session;
vm.sessions = Auth.sessions; vm.sessions = Auth.sessions;
@ -50,19 +52,16 @@ app.controller('loginCtrl', [
} }
return Oauth3.discover(url, { client_uri: Oauth3.clientUri(location) }).then(function (deets) { return Oauth3.discover(url, { client_uri: Oauth3.clientUri(location) }).then(function (deets) {
console.log('discover', url);
console.log(deets);
vm.currentIssuer = url; vm.currentIssuer = url;
vm.issuerName = url; vm.issuerName = url;
return vm.oauth3.setIdentityProvider(url).then(function (deets) { return vm.newOauth3.setIdentityProvider(url).then(function (deets) {
vm.oauth3.setResourceProvider(url); vm.newOauth3.setResourceProvider(url);
vm.spinner = false; vm.spinner = false;
// TODO add icon and name to directives // TODO add icon and name to directives
console.log(deets);
}); });
}, function () { }, function () {
console.log('oauth3 timeout: No dice, no change'); console.log("oauth3 discover timeout: No dice, no change for '" + url + "'");
vm.spinner = false; vm.spinner = false;
}); });
}; };
@ -77,7 +76,7 @@ app.controller('loginCtrl', [
vm.setAudience = function (url) { vm.setAudience = function (url) {
url = url || vm.audienceUrl; url = url || vm.audienceUrl;
vm.audienceName = url; vm.audienceName = url;
vm.oauth3.setResourceProvider(url); vm.newOauth3.setResourceProvider(url);
}; };
vm.selectSession = function (session) { vm.selectSession = function (session) {
@ -85,7 +84,6 @@ app.controller('loginCtrl', [
vm.session = session; vm.session = session;
return Auth.select(session).then(function (oauth3) { return Auth.select(session).then(function (oauth3) {
vm.xauth = false; vm.xauth = false;
vm.oauth3 = oauth3;
}); });
}; };
@ -100,11 +98,10 @@ app.controller('loginCtrl', [
vm.auth = function () { vm.auth = function () {
var subject = vm.currentSubject; var subject = vm.currentSubject;
var issuer = vm.issuerName; var issuer = vm.issuerName;
return vm.oauth3.authenticate({ return vm.newOauth3.authenticate({
subject: subject subject: subject
, scope: [ 'domains@oauth3.org', 'domains', 'dns@oauth3.org', 'dns', 'www@daplie.com' ] , scope: [ 'domains@oauth3.org', 'domains', 'dns@oauth3.org', 'dns', 'www@daplie.com' ]
}).then(function (session) { }).then(function (session) {
console.log('vm.auth session.issuer', session.issuer);
session.subject = subject; session.subject = subject;
session.issuer = issuer; session.issuer = issuer;
Auth.add(session); Auth.add(session);
@ -114,8 +111,8 @@ app.controller('loginCtrl', [
$location.path('/' + $rootScope.redirectedURL); $location.path('/' + $rootScope.redirectedURL);
} }
}, function (err) { }, function (err) {
console.log('auth error'); console.error('auth error');
console.log(err); console.error(err);
}); });
}; };

View File

@ -20,7 +20,8 @@ function handleFiles(ev) {
vm.unzip = vm.isZip; vm.unzip = vm.isZip;
vm.stripZip = vm.isZip; vm.stripZip = vm.isZip;
$scope.$digest(); $scope.$digest();
console.log('vm.currentFiles', vm.currentFiles); console.log('[handleFiles] vm.currentFiles:');
console.log(vm.currentFiles);
} }
window.document.body.addEventListener('change', handleFiles); window.document.body.addEventListener('change', handleFiles);
@ -98,12 +99,12 @@ app.controller('websiteCtrl', [
}; };
vm.selectDomain = function (domain) { vm.selectDomain = function (domain) {
vm.domain = domain; vm.domain = domain; //vm.selectedDomain.description;
vm.newDomain = domain.domain; vm.newDomain = vm.domain.domain;
return Auth.api('dns.list', { }).then(function (records) { return Auth.api('dns.list', { }).then(function (records) {
records = records.filter(function (r) { records = records.filter(function (r) {
return /^A(AAA)?$/i.test(r.type) && ((r.sld + '.' + r.tld) === domain || r.zone === domain.domain); return /^A(AAA)?$/i.test(r.type) && ((r.sld + '.' + r.tld) === vm.domain.domain || r.zone === vm.domain.domain);
}); });
vm.records = records; vm.records = records;
records.forEach(function (record) { records.forEach(function (record) {
@ -114,7 +115,8 @@ app.controller('websiteCtrl', [
} }
} }
}); });
console.log('dns records', records); console.log('[selectDomain] dns records:');
console.log(records);
}); });
}; };
@ -128,8 +130,8 @@ app.controller('websiteCtrl', [
vm.record = { sub: sub, host: (sub ? sub + '.' : '') + vm.domain.domain }; vm.record = { sub: sub, host: (sub ? sub + '.' : '') + vm.domain.domain };
vm.currentHost = vm.record.host; vm.currentHost = vm.record.host;
console.log('vm.record', vm.record); console.log('[setRecord] vm.record:');
console.log('vm.currentHost', vm.currentHost); console.log(vm.record);
}; };
vm.selectRecord = function (record) { vm.selectRecord = function (record) {
@ -160,9 +162,6 @@ app.controller('websiteCtrl', [
vm.Sites = {}; vm.Sites = {};
vm.Sites.create = function () { vm.Sites.create = function () {
console.log('##### Auth.oauth3');
console.log(Auth.oauth3);
var pkg = Auth.oauth3.pkg('www@daplie.com'); var pkg = Auth.oauth3.pkg('www@daplie.com');
var parts; var parts;
var sub; var sub;
@ -217,31 +216,19 @@ app.controller('websiteCtrl', [
var sess; var sess;
var prom; var prom;
var def; var def;
console.log('[pkg www] request domain');
console.log(result.data);
console.log('[pkg www] vm.domain.session:');
console.log(vm.domain.session);
console.log(vm.currentHost, vm.domain.domain);
console.log(vm._isSubDomain(vm.currentHost, vm.domain.domain));
// can validate automatically // can validate automatically
if (vm.domain.session && vm._isSubDomain(vm.currentHost, vm.domain.domain)) { if (vm.domain.session && vm._isSubDomain(vm.currentHost, vm.domain.domain)) {
// this should always succeed // this should always succeed
Auth.sessions.some(function (session) { Auth.sessions.some(function (session) {
console.log('#', session.token.sub + '@' + session.token.iss);
if (vm.domain.session === (session.token.sub + '@' + session.token.iss)) { if (vm.domain.session === (session.token.sub + '@' + session.token.iss)) {
console.log('=', session.token.sub + '@' + session.token.iss);
sess = session; sess = session;
return session; return session;
} }
}); });
if (sess) { if (sess) {
console.log('[pkg www] session selected', sess);
prom = Auth.get(sess).then(function (oauth3) { prom = Auth.get(sess).then(function (oauth3) {
console.log('[pkg www] instance selected', oauth3);
return oauth3.api('dns.set', { sld: sld, tld: tld, sub: ('' + result.data.prefix), type: 'TXT', ttl: 300, value: result.data.challenge }); return oauth3.api('dns.set', { sld: sld, tld: tld, sub: ('' + result.data.prefix), type: 'TXT', ttl: 300, value: result.data.challenge });
}); });
} }
@ -260,10 +247,7 @@ app.controller('websiteCtrl', [
} }
return prom.then(function () { return prom.then(function () {
console.log('[pkg www] after pkg');
console.log(pkg);
return pkg.claim(domainReq).then(function (result) { return pkg.claim(domainReq).then(function (result) {
console.log('[pkg www] claim', result);
return vm._createWebsite(pkg); return vm._createWebsite(pkg);
}); });
}); });
@ -310,7 +294,6 @@ app.controller('websiteCtrl', [
return $q.all(Auth.sessions.map(function (session) { return $q.all(Auth.sessions.map(function (session) {
console.log('[www] select');
return Auth.get(session).then(function (oauth3) { return Auth.get(session).then(function (oauth3) {
var pkg = oauth3.pkg('www@daplie.com'); var pkg = oauth3.pkg('www@daplie.com');
@ -330,7 +313,7 @@ app.controller('websiteCtrl', [
}); });
}); });
})).then(function () { })).then(function () {
console.log('[www] sites'); console.log('[listSites] sites:');
console.log(sites); console.log(sites);
vm.sites = sites; vm.sites = sites;
}); });
@ -338,7 +321,8 @@ app.controller('websiteCtrl', [
//vm.getDomains(); //vm.getDomains();
Auth.api('domains.list', {}).then(function (els) { Auth.api('domains.list', {}).then(function (els) {
console.log('domains.list els', els); console.log('[init] domains.list els:');
console.log(els);
vm.domains = els; vm.domains = els;
$scope.domain = vm.domains; $scope.domain = vm.domains;
}); });
@ -353,7 +337,7 @@ app.controller('websiteCtrl', [
$scope.$watch('vm.selectedDomain', function (domainSelected) { $scope.$watch('vm.selectedDomain', function (domainSelected) {
if (domainSelected !== undefined) { if (domainSelected !== undefined) {
vm.selectDomain(vm.selectedDomain.title); vm.selectDomain(vm.selectedDomain.description);
} }
}); });

View File

@ -25,8 +25,6 @@ app.factory('Auth', [
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;
console.log('add session', session);
/* /*
Object.keys(Auth.session).forEach(function (key) { Object.keys(Auth.session).forEach(function (key) {
delete Auth.session[key]; delete Auth.session[key];
@ -64,9 +62,17 @@ app.factory('Auth', [
Auth.sessions.push(session); Auth.sessions.push(session);
}); });
if (Auth.session) {
Auth.select(Auth.session);
}
return Auth.session; return Auth.session;
} }
, get: function (session) { , get: function (session) {
if (!session) {
return $q.resolve(null);
}
if (!session.issuer) { if (!session.issuer) {
throw new Error("session doesn't have an issuer"); throw new Error("session doesn't have an issuer");
} }
@ -83,20 +89,12 @@ app.factory('Auth', [
, audience: session.audience || session.issuer , audience: session.audience || session.issuer
, session: session , session: session
}).then(function () { }).then(function () {
console.log('a Auth._oauth3s[name]', Auth._oauth3s[name]);
console.log('_resourceProviderDirectives', Auth._oauth3s[name]._resourceProviderDirectives);
return sess; return sess;
}); });
} else { } else {
console.log('b Auth._oauth3s[name]', Auth._oauth3s[name]);
console.log('_resourceProviderDirectives', Auth._oauth3s[name]._resourceProviderDirectives);
promise = Oauth3.PromiseA.resolve(Auth._oauth3s[name]); promise = Oauth3.PromiseA.resolve(Auth._oauth3s[name]);
} }
console.log('session.issuer:', session.issuer);
console.log('session.subject:', session.subject);
console.log('session:', session);
return promise; return promise;
} }
, select: function (session) { , select: function (session) {

View File

@ -18,20 +18,20 @@
</form> </form>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li class="dropdown"> <li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span ng-bind="vm.session.subject">me@example.com</span> <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span ng-bind="vm.Auth.session.subject">me@example.com</span>
<i class="fa fa-user" aria-hidden="true"></i> <span class="caret"></span> <i class="fa fa-user" aria-hidden="true"></i> <span class="caret"></span>
<br><small ng-bind="vm.session.issuer">example.com</small></a> <br><small ng-bind="vm.Auth.session.issuer">example.com</small></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="feed.html" target="_blank">Preview My Public Site</a></li> <li><a href="feed.html" target="_blank">Preview My Public Site</a></li>
<li><a href="#!/account-settings">Account Settings</a></li> <li><a href="#!/account-settings">Account Settings</a></li>
<li role="separator" class="divider"></li> <li role="separator" class="divider"></li>
<li ng-if="vm.sessions.length">Switch User</li> <li ng-if="vm.Auth.sessions.length">Switch User</li>
<li ng-repeat="session in vm.sessions track by $index"><a ng-click="vm.selectSession(session);"><span ng-bind="session.subject">me@example.com</span> <i class="fa fa-user" aria-hidden="true"></i> <li ng-repeat="session in vm.Auth.sessions track by $index"><a ng-click="vm.selectSession(session);"><span ng-bind="session.subject">me@example.com</span> <i class="fa fa-user" aria-hidden="true"></i>
<br><small ng-bind="session.issuer">example.com</small></a></li> <br><small ng-bind="session.issuer">example.com</small></a></li>
<li ng-if="vm.sessions.length" role="separator" class="divider"></li> <li ng-if="vm.Auth.sessions.length" role="separator" class="divider"></li>
<li>Add User <i class="fa fa-cog" aria-hidden="true" ng-click="vm.toggleAdvanced()"></i> <li>Add User <i class="fa fa-cog" aria-hidden="true" ng-click="vm.toggleAdvanced()"></i>
<br><input class="input" type="text" ng-model="vm.newSubject" ng-change="vm.setSubject()" /> <br><input class="input" type="text" ng-model="vm.newSubject" ng-change="vm.setSubject()" />

View File

@ -1,7 +1,7 @@
<section class="col-md-offset-4 col-md-4 login-container" ng-init="vm.initListLoggedInProfiles()"> <section class="col-md-offset-4 col-md-4 login-container" ng-init="vm.initListLoggedInProfiles()">
<form> <form>
<h4 class="text-center">Sign in</h4> <h4 class="text-center">Sign in</h4>
<a href="#!/home" class="current-user-container" ng-repeat="profile in vm.sessions track by $index" ng-click="vm.selectSession(profile);"> <a href="#!/home" class="current-user-container" ng-repeat="profile in vm.Auth.sessions track by $index" ng-click="vm.selectSession(profile);">
<div class="current-user-split"><i class="fa fa-user"></i></div> <div class="current-user-split"><i class="fa fa-user"></i></div>
<div class="current-user-text">Resume with {{ profile.email }}</div> <div class="current-user-text">Resume with {{ profile.email }}</div>
</a> </a>