Store repo credentials per-user

This commit is contained in:
Nick O'Leary
2017-12-06 22:39:30 +00:00
parent f86d3a69d2
commit 304c597a2f
3 changed files with 66 additions and 45 deletions

View File

@@ -17,23 +17,26 @@
var authCache = {}
module.exports = {
clear: function(project,remote) {
if (remote && authCache.hasOwnProperty(project)) {
clear: function(project,remote, user) {
if (user && remote && authCache[project] && authCache[project][remote]) {
delete authCache[project][remote][user];
} else if (remote && authCache.hasOwnProperty(project)) {
delete authCache[project][remote];
return;
} else {
delete authCache[project];
}
delete authCache[project];
},
set: function(project,remote,auth) {
console.log("AuthCache.set",remote,auth);
set: function(project,remote,user,auth) {
// console.log("AuthCache.set",remote,user,auth);
authCache[project] = authCache[project]||{};
authCache[project][remote] = auth;
authCache[project][remote] = authCache[project][remote]||{};
authCache[project][remote][user] = auth;
// console.log(JSON.stringify(authCache,'',4));
},
get: function(project,remote) {
console.log("AuthCache.get",remote,authCache[project]&&authCache[project][remote]);
if (authCache.hasOwnProperty(project)) {
return authCache[project][remote];
get: function(project,remote,user) {
// console.log("AuthCache.get",remote,user,authCache[project]&&authCache[project][remote]&&authCache[project][remote][user]);
if (authCache[project] && authCache[project][remote]) {
return authCache[project][remote][user];
}
return
}