Fix reauthentication of remote repositories

This commit is contained in:
Nick O'Leary
2017-12-21 17:40:24 +00:00
parent 3c6ba72a2a
commit 9c350311e8
9 changed files with 184 additions and 286 deletions

View File

@@ -512,6 +512,23 @@ module.exports = {
});
});
// Update a remote
app.put("/:id/remotes/:remoteName", needsPermission("projects.write"), function(req,res) {
var projectName = req.params.id;
var remoteName = req.params.remoteName;
runtime.storage.projects.updateRemote(req.user, projectName, remoteName, req.body).then(function(data) {
res.status(204).end();
})
.catch(function(err) {
if (err.code) {
res.status(400).json({error:err.code, message: err.message});
} else {
res.status(400).json({error:"unexpected_error", message:err.toString()});
}
});
});
return app;
}
}

View File

@@ -63,12 +63,15 @@ module.exports = {
// console.log('username:', username);
runtime.storage.sshkeys.getSSHKey(username, req.params.id)
.then(function(data) {
res.json({
publickey: data
});
if (data) {
res.json({
publickey: data
});
} else {
res.status(404).end();
}
})
.catch(function(err) {
console.log(err.stack);
if (err.code) {
res.status(400).json({error:err.code, message: err.message});
} else {
@@ -90,7 +93,6 @@ module.exports = {
});
})
.catch(function(err) {
console.log(err.stack);
if (err.code) {
res.status(400).json({error:err.code, message: err.message});
} else {
@@ -107,11 +109,10 @@ module.exports = {
app.delete("/:id", needsPermission("settings.write"), function(req,res) {
var username = getUsername(req.user);
runtime.storage.sshkeys.deleteSSHKey(username, req.params.id)
.then(function(ret) {
.then(function() {
res.status(204).end();
})
.catch(function(err) {
console.log(err.stack);
if (err.code) {
res.status(400).json({error:err.code, message: err.message});
} else {