Skip to content

Commit

Permalink
Actually fix collaborators router
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Radchenko committed Sep 9, 2016
1 parent ed75a90 commit fa32742
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ exports.init = function (config) {
app.use(providerRouter);

// collaborators
app.use('/:org/:repo/collaborators', collaboratorsRouter);
app.use(collaboratorsRouter);

// branches
app.use('/:org/:repo/branches/',
Expand Down
15 changes: 8 additions & 7 deletions lib/routes/collaborators/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ var api = require('./api');
var router = new express.Router();
var User = models.User;

router.route('/').all(
router.route('/:org/:repo/collaborators/')
.all(
auth.requireUserOr401,
middleware.project,
auth.requireProjectAdmin
);
)

/**
* @api {get} /:org/:repo/collaborators Get Collaborators
Expand All @@ -27,7 +28,7 @@ router.route('/').all(
* @apiExample {curl} CURL Example:
* curl -X GET http://localhost/api/strider-cd/strider/collaborators
*/
router.route('/').get(function getCollab(req, res) {
.get(function getCollab(req, res) {
var project = `${req.params.org}/${req.params.repo}`;

User.collaborators(project, 0, function (err, users) {
Expand All @@ -48,7 +49,7 @@ router.route('/').get(function getCollab(req, res) {
}
res.send(results);
});
});
})

/**
* @api {post} /:org/:repo/collaborators Add Collaborator
Expand All @@ -68,7 +69,7 @@ router.route('/').get(function getCollab(req, res) {
* @apiParam (RequestBody) {Number} access=0 Access level to grant to the
* new collaborator. This can be `0`, for read only access, or `2` for admin access.
*/
router.route('/').post(middleware.requireBody(['email']), function addCollab(req, res) {
.post(middleware.requireBody(['email']), function addCollab(req, res) {
var project = `${req.params.org}/${req.params.repo}`;
var accessLevel = req.body.access || 0;
var email = req.body.email;
Expand All @@ -87,7 +88,7 @@ router.route('/').post(middleware.requireBody(['email']), function addCollab(req
message: `An invitation email has already been sent to ${email}. They will become a collaborator when they create an account.`
});
});
});
})

/**
* @api {delete} /:org/:repo/collaborators Delete Collaborator
Expand All @@ -103,7 +104,7 @@ router.route('/').post(middleware.requireBody(['email']), function addCollab(req
*
* @apiParam (RequestBody) {String} email Email address to remove from the repo/project.
*/
router.route('/').delete(middleware.requireBody(['email']), function delCollab(req, res) {
.delete(middleware.requireBody(['email']), function delCollab(req, res) {
var project = `${req.params.org}/${req.params.repo}`;
var email = req.body.email;

Expand Down

0 comments on commit fa32742

Please sign in to comment.