diff --git a/assets/oauth3.org b/assets/oauth3.org index 1fe8733..db284fb 160000 --- a/assets/oauth3.org +++ b/assets/oauth3.org @@ -1 +1 @@ -Subproject commit 1fe8733a064c55024bc384691813772d4c94665d +Subproject commit db284fbf911dc4f9d0cb99bb512d9663dcfd0ece diff --git a/index.html b/index.html index 723b13c..bc837ed 100644 --- a/index.html +++ b/index.html @@ -27,6 +27,7 @@ + diff --git a/js/controllers/email-controller.js b/js/controllers/email-controller.js index d39e0e6..9e6035b 100644 --- a/js/controllers/email-controller.js +++ b/js/controllers/email-controller.js @@ -1,5 +1,16 @@ app.controller('emailCtrl', [ - '$scope', - function($scope) { - var vm = this; -}]); + '$scope', '$q', 'Auth', 'azp@oauth3.org', '$timeout' +, function ($scope, $q, Auth, Oauth3, $timeout) { + var vm = this; + + vm.getSettings = function () { + var pkg = Auth.oauth3.pkg('email@daplie.com'); + return pkg.settings().then(function (resp) { + vm.settings.service = 'mailgun.org'; + vm.settings = resp.data; + }); + }; + + vm.getSettings(); + } +]); diff --git a/js/controllers/website-controller.js b/js/controllers/website-controller.js index 0b9e2b8..714bf43 100644 --- a/js/controllers/website-controller.js +++ b/js/controllers/website-controller.js @@ -303,13 +303,38 @@ app.controller('websiteCtrl', [ , domain: r.domain , tld: r.tld , sld: r.sld - //, sub: vm.record.sub + //, sub: r.sub , path: r.newPath }).then(function (result) { window.alert(JSON.stringify(result)); }); }; + vm.Shares = {}; + vm.Shares.invite = function (r) { + var pkg = Auth.oauth3.pkg('www@daplie.com'); + return pkg.invite({ + email: r.shareEmail + , domain: r.domain + , tld: r.tld + , sld: r.sld + //, sub: r.sub + , path: r.sharePath + , mode: r.shareMode + }).then(function (result) { + window.alert(JSON.stringify(result)); + }); + }; + vm.Shares.accept = function () { + var pkg = Auth.oauth3.pkg('www@daplie.com'); + return pkg.acceptInvite({ + token: vm.Shares.inviteToken + }).then(function (result) { + window.alert(JSON.stringify(result)); + vm.listSites(); + }); + }; + vm.listSites = function () { var sites = []; diff --git a/js/email@daplie.com.js b/js/email@daplie.com.js new file mode 100644 index 0000000..8a3f2f8 --- /dev/null +++ b/js/email@daplie.com.js @@ -0,0 +1,22 @@ +;(function (exports) { +'use strict'; + +var OAUTH3 = exports.OAUTH3 = exports.OAUTH3 || require('./oauth3.core.js').OAUTH3; + +OAUTH3._pkgs['email@daplie.com'] = { + settings: function (opts) { + var providerUri = opts.audience; + var session = opts.session; + + return OAUTH3.request({ + method: 'GET' + , url: OAUTH3.url.normalize(providerUri) + + '/api/email@daplie.com/acl/settings/' + , session: session + }).then(function (result) { + return result; + }); + } +}; + +}('undefined' !== typeof exports ? exports : window)); diff --git a/js/www@daplie.com.js b/js/www@daplie.com.js index b2d3ccc..e7613d2 100644 --- a/js/www@daplie.com.js +++ b/js/www@daplie.com.js @@ -28,6 +28,36 @@ OAUTH3._pkgs['www@daplie.com'] = { + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, strip: opts.strip, path: opts.path }) ; } +, invite: function (opts) { + var providerUri = opts.audience; + var session = opts.session; + + // TODO needs a way to have api and assets for audience + return OAUTH3.request({ + method: 'POST' + , url: OAUTH3.url.normalize(providerUri) + + '/api/www@daplie.com/acl/shares/' + (opts.domain || opts.hostname) + + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/, mode: opts.mode, path: opts.path }) + , session: session + }).then(function (result) { + return result; + }); + } +, acceptInvite: function (opts) { + var providerUri = opts.audience; + var session = opts.session; + + // TODO needs a way to have api and assets for audience + return OAUTH3.request({ + method: 'POST' + , url: OAUTH3.url.normalize(providerUri) + + '/api/www@daplie.com/acl/shares/accept/' + opts.token + + '?' + OAUTH3.utils.query.stringify({ tld: opts.tld, sld: opts.sld/*, sub: opts.sub*/ }) + , session: session + }).then(function (result) { + return result; + }); + } , download: function (opts) { var session = opts.session; var me = this; diff --git a/templates/email.html b/templates/email.html index 8fce953..8f37182 100644 --- a/templates/email.html +++ b/templates/email.html @@ -66,6 +66,19 @@ + + +