fix some state issues

This commit is contained in:
aj 2017-08-23 18:54:50 +00:00
parent 8a4b19928a
commit 37734638b8
2 changed files with 12 additions and 10 deletions

View File

@ -31,7 +31,7 @@ app.controller('websiteCtrl', [
return $q.all(Auth.sessions.map(function (session) {
return Auth.select(session).then(function (oauth3) {
return Auth.get(session).then(function (oauth3) {
return oauth3.api(apiname, {}).then(function (collection) {
@ -201,7 +201,7 @@ app.controller('websiteCtrl', [
if (sess) {
console.log('[pkg www] session selected', sess);
prom = Auth.select(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 });
});
@ -238,10 +238,8 @@ app.controller('websiteCtrl', [
return $q.all(Auth.sessions.map(function (session) {
console.log('[www] select');
return Auth.select(session).then(function (oauth3) {
console.log('[www] oauth3', oauth3._resourceProviderDirectives);
return Auth.get(session).then(function (oauth3) {
var pkg = oauth3.pkg('www@daplie.com');
console.log('[www] post pkg', oauth3._resourceProviderDirectives);
return pkg.list().then(function (result) {
var _sites = result.data;

View File

@ -66,7 +66,7 @@ app.factory('Auth', [
});
return Auth.session;
}
, select: function (session) {
, get: function (session) {
if (!session.issuer) {
throw new Error("session doesn't have an issuer");
}
@ -97,12 +97,16 @@ app.factory('Auth', [
console.log('session.subject:', session.subject);
console.log('session:', session);
promise.then(function (oauth3) {
return promise;
}
, select: function (session) {
return Auth.get(session).then(function (oauth3) {
var dapName = 'dap-' + session.subject + '|' + session.issuer;
localStorage.setItem(dapSession, dapName);
Auth.session = session;
Auth.oauth3 = oauth3;
})
return promise;
});
}
, signOut: function () {
var session = Auth.session;