almost got it.

This commit is contained in:
Jon Lambson 2017-11-07 14:45:11 -07:00
parent d0ea91c0bb
commit 3bcc504ab2
2 changed files with 31 additions and 22 deletions

View File

@ -129,7 +129,6 @@ app.controller('websiteCtrl', [
}; };
vm.setDomain = function () { vm.setDomain = function () {
debugger;
if (!vm.domains || !vm.domains.length) { if (!vm.domains || !vm.domains.length) {
vm.domain = { domain: vm.newDomain }; vm.domain = { domain: vm.newDomain };
return; return;
@ -180,7 +179,6 @@ app.controller('websiteCtrl', [
vm.setRecordDomain = function(domain) { vm.setRecordDomain = function(domain) {
vm.domain.sub = vm.newRecord || ''; vm.domain.sub = vm.newRecord || '';
if (vm.record !== undefined) { if (vm.record !== undefined) {
debugger;
domain.title = vm.record.host; domain.title = vm.record.host;
domain.description.domain = vm.record.host; domain.description.domain = vm.record.host;
domain.originalObject.domain = vm.record.host; domain.originalObject.domain = vm.record.host;
@ -245,7 +243,7 @@ app.controller('websiteCtrl', [
, domain: opts.domain , domain: opts.domain
, tld: opts.tld , tld: opts.tld
, sld: opts.sld , sld: opts.sld
//, sub: opts.record.sub , sub: opts.sub
, multipart: { site: opts.newFile } , multipart: { site: opts.newFile }
, progress: function (ev) { , progress: function (ev) {
// TODO must digest // TODO must digest
@ -299,6 +297,7 @@ app.controller('websiteCtrl', [
return; return;
} }
*/ */
debugger;
if (!vm.newFile) { if (!vm.newFile) {
window.alert('No file chosen.'); window.alert('No file chosen.');
return; return;
@ -324,6 +323,7 @@ app.controller('websiteCtrl', [
sld = parts.pop(); sld = parts.pop();
sub = parts.join('.'); sub = parts.join('.');
} }
if (vm.sites.some(function (r) { if (vm.sites.some(function (r) {
return (-1 !== ('.' + vm.currentHost).indexOf(('.' + r.domain))) && domainIsVerified(r); return (-1 !== ('.' + vm.currentHost).indexOf(('.' + r.domain))) && domainIsVerified(r);
})) { })) {
@ -336,10 +336,12 @@ app.controller('websiteCtrl', [
// We're claiming it at the top level (i.e. example.com) // We're claiming it at the top level (i.e. example.com)
// but we could also claim it at the subdomain level (needs UI update) // but we could also claim it at the subdomain level (needs UI update)
var domainReq = { sld: sld, tld: tld, sub: sub }; var domainReq = { sld: sld, tld: tld, sub: sub };
debugger;
return pkg.request(domainReq).then(function (result) { return pkg.request(domainReq).then(function (result) {
var sess; var sess;
var prom; var prom;
var def; var def;
var sub;
// 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)) {
@ -353,7 +355,11 @@ app.controller('websiteCtrl', [
if (sess) { if (sess) {
prom = Auth.get(sess).then(function (oauth3) { prom = Auth.get(sess).then(function (oauth3) {
return oauth3.api('dns.set', { sld: sld, tld: tld, sub: ('' + result.data.prefix), type: 'TXT', ttl: 300, value: result.data.challenge }); sub = result.data.prefix;
if (result.data.sub) {
sub = result.data.sub + '.' + result.data.prefix;
}
return oauth3.api('dns.set', { sld: sld, tld: tld, sub: sub, type: 'TXT', ttl: 5, value: result.data.challenge });
}); });
} }
} }
@ -715,18 +721,18 @@ app.controller('websiteCtrl', [
if (!window.confirm("Delete this site?")) { if (!window.confirm("Delete this site?")) {
return; return;
} }
s.sharePath = '/';
vm.Shares.remove(r, s); vm.Shares.remove(r, s);
}; };
vm.Shares.remove = function (r, s) { vm.Shares.remove = function (r, s) {
console.log('Shares.remove');
var pkg = Auth.oauth3.pkg('www@daplie.com'); var pkg = Auth.oauth3.pkg('www@daplie.com');
return pkg.removeShare({ return pkg.removeShare({
domain: s.domain domain: s.domain
, hostname: s.domain , hostname: s.domain
, tld: s.tld , tld: s.tld
, sld: s.sld , sld: s.sld
//, sub: r.sub , sub: r.sub
, path: s.sharePath , path: s.sharePath
, challenge: s.challenge , challenge: s.challenge
}).then(function (result) { }).then(function (result) {
@ -737,6 +743,7 @@ app.controller('websiteCtrl', [
console.log(result); console.log(result);
var index; var index;
if (r.sharedWith !== undefined) {
r.sharedWith.forEach(function (_s, i) { r.sharedWith.forEach(function (_s, i) {
if (s.challenge === _s.challenge) { if (s.challenge === _s.challenge) {
index = i; index = i;
@ -745,6 +752,7 @@ app.controller('websiteCtrl', [
r.sharedWith.splice(index, 1); r.sharedWith.splice(index, 1);
//r.usersnames = r.sharedWith.map().join(','); //r.usersnames = r.sharedWith.map().join(',');
}
}); });
}; };

View File

@ -13,7 +13,7 @@ OAUTH3._pkgs['www@daplie.com'] = {
, url: OAUTH3.url.normalize(providerUri) , url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/sites/' + opts.hostname + '/api/www@daplie.com/acl/sites/' + opts.hostname
+ '?' + OAUTH3.utils.query.stringify({ + '?' + OAUTH3.utils.query.stringify({
tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, unzip: opts.unzip tld: opts.tld, sld: opts.sld, sub: opts.sub, unzip: opts.unzip
, strip: opts.strip, path: opts.path , strip: opts.strip, path: opts.path
}) })
, session: session , session: session
@ -28,7 +28,7 @@ OAUTH3._pkgs['www@daplie.com'] = {
return OAUTH3.url.normalize(providerUri.replace(/api\./, 'assets.')) return OAUTH3.url.normalize(providerUri.replace(/api\./, 'assets.'))
+ '/assets/www@daplie.com/acl/archives/' + opts.hostname + '/assets/www@daplie.com/acl/archives/' + opts.hostname
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, strip: opts.strip, path: opts.path }) + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub, strip: opts.strip, path: opts.path })
; ;
} }
, listShares: function (opts) { , listShares: function (opts) {
@ -40,7 +40,7 @@ OAUTH3._pkgs['www@daplie.com'] = {
method: 'GET' method: 'GET'
, url: OAUTH3.url.normalize(providerUri) , url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/shares/' + (opts.domain || opts.hostname) + '/api/www@daplie.com/acl/shares/' + (opts.domain || opts.hostname)
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, path: opts.path }) + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub, path: opts.path })
, session: session , session: session
}).then(function (result) { }).then(function (result) {
return result; return result;
@ -49,13 +49,14 @@ OAUTH3._pkgs['www@daplie.com'] = {
, removeShare: function (opts) { , removeShare: function (opts) {
var providerUri = opts.audience; var providerUri = opts.audience;
var session = opts.session; var session = opts.session;
debugger;
// TODO needs a way to have api and assets for audience // TODO needs a way to have api and assets for audience
return OAUTH3.request({ return OAUTH3.request({
method: 'DELETE' method: 'DELETE'
, url: OAUTH3.url.normalize(providerUri) , url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/shares/' + (opts.domain || opts.hostname) + '/' + (opts.challenge || opts.token) + '/api/www@daplie.com/acl/shares/' + (opts.domain || opts.hostname) + '/' + (opts.challenge || opts.token)
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, path: opts.path }) + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub, path: opts.path })
, session: session , session: session
}).then(function (result) { }).then(function (result) {
return result; return result;
@ -93,7 +94,7 @@ OAUTH3._pkgs['www@daplie.com'] = {
method: 'POST' method: 'POST'
, url: OAUTH3.url.normalize(providerUri) , url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/shares/accept/' + opts.token + '/api/www@daplie.com/acl/shares/accept/' + opts.token
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/ }) + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub })
, session: session , session: session
}).then(function (result) { }).then(function (result) {
return result; return result;
@ -134,7 +135,7 @@ OAUTH3._pkgs['www@daplie.com'] = {
method: 'GET' method: 'GET'
, url: OAUTH3.url.normalize(providerUri) , url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/fs/' + opts.hostname + '/api/www@daplie.com/acl/fs/' + opts.hostname
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, path: opts.path }) + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub, path: opts.path })
, session: session , session: session
}).then(function (result) { }).then(function (result) {
return result; return result;
@ -148,7 +149,7 @@ OAUTH3._pkgs['www@daplie.com'] = {
method: 'GET' method: 'GET'
, url: OAUTH3.url.normalize(providerUri) , url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/fs/' + opts.hostname + '/api/www@daplie.com/acl/fs/' + opts.hostname
+ '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, path: opts.path + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld, sub: opts.sub, path: opts.path
, offset: opts.offset, length: opts.length, json: true }) , offset: opts.offset, length: opts.length, json: true })
, session: session , session: session
}).then(function (result) { }).then(function (result) {
@ -158,13 +159,14 @@ OAUTH3._pkgs['www@daplie.com'] = {
, remove: function (opts) { , remove: function (opts) {
var providerUri = opts.audience; var providerUri = opts.audience;
var session = opts.session; var session = opts.session;
debugger;
return OAUTH3.request({ return OAUTH3.request({
method: 'DELETE' method: 'DELETE'
, url: OAUTH3.url.normalize(providerUri) , url: OAUTH3.url.normalize(providerUri)
+ '/api/www@daplie.com/acl/sites/' + opts.hostname + '/api/www@daplie.com/acl/sites/' + opts.hostname
+ '?' + OAUTH3.utils.query.stringify({ + '?' + OAUTH3.utils.query.stringify({
tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/ tld: opts.tld, sld: opts.sld, sub: opts.sub
, path: opts.path, confirm: opts.confirm , path: opts.path, confirm: opts.confirm
}) })
, session: session , session: session
@ -202,7 +204,6 @@ OAUTH3._pkgs['www@daplie.com'] = {
, session: session , session: session
}).then(function (result) { }).then(function (result) {
// result.data // result.data
return result; return result;
}); });
} }