Permalink
Browse files

cnodejs github users are admins

  • Loading branch information...
1 parent 2565824 commit f38f4e5107c85eb3eb7b6282e05424b875af17a9 @thoward thoward committed Aug 3, 2012
Showing with 14,331 additions and 8 deletions.
  1. +22 −5 app.js
  2. +3 −0 node_modules/github/.npmignore
  3. +21 −0 node_modules/github/LICENSE
  4. +128 −0 node_modules/github/README.md
  5. +3 −0 node_modules/github/api/v2.0.0/routes.json
  6. +435 −0 node_modules/github/api/v3.0.0/events.js
  7. +229 −0 node_modules/github/api/v3.0.0/eventsTest.js
  8. +497 −0 node_modules/github/api/v3.0.0/gists.js
  9. +245 −0 node_modules/github/api/v3.0.0/gistsTest.js
  10. +574 −0 node_modules/github/api/v3.0.0/gitdata.js
  11. +305 −0 node_modules/github/api/v3.0.0/gitdataTest.js
  12. +39 −0 node_modules/github/api/v3.0.0/index.js
  13. +965 −0 node_modules/github/api/v3.0.0/issues.js
  14. +507 −0 node_modules/github/api/v3.0.0/issuesTest.js
  15. +953 −0 node_modules/github/api/v3.0.0/orgs.js
  16. +474 −0 node_modules/github/api/v3.0.0/orgsTest.js
  17. +663 −0 node_modules/github/api/v3.0.0/pullRequests.js
  18. +352 −0 node_modules/github/api/v3.0.0/pullRequestsTest.js
  19. +2,002 −0 node_modules/github/api/v3.0.0/repos.js
  20. +1,019 −0 node_modules/github/api/v3.0.0/reposTest.js
  21. +2,438 −0 node_modules/github/api/v3.0.0/routes.json
  22. +743 −0 node_modules/github/api/v3.0.0/user.js
  23. +363 −0 node_modules/github/api/v3.0.0/userTest.js
  24. +117 −0 node_modules/github/error.js
  25. +227 −0 node_modules/github/generate.js
  26. +534 −0 node_modules/github/index.js
  27. +55 −0 node_modules/github/package.json
  28. +5 −0 node_modules/github/seed.yml
  29. +10 −0 node_modules/github/templates/after_request.js.tpl
  30. +21 −0 node_modules/github/templates/handler.js.tpl
  31. +39 −0 node_modules/github/templates/index.js.tpl
  32. +23 −0 node_modules/github/templates/section.js.tpl
  33. +15 −0 node_modules/github/templates/test_handler.js.tpl
  34. +28 −0 node_modules/github/templates/test_section.js.tpl
  35. +37 −0 node_modules/github/test/example.js
  36. +95 −0 node_modules/github/test/oauth.js
  37. +140 −0 node_modules/github/util.js
  38. +5 −3 package.json
View
27 app.js
@@ -76,11 +76,28 @@ var authRequired = function (req, res, next) {
var adminRequired = function (req, res, next) {
var user = req.session.oauthUser;
- if (config.admins.indexOf(user.t_url) !== -1) {
- next();
- } else {
- res.send(401, {'status': 'fail', 'message': 'unauthorized'});
- }
+
+ var GitHubApi = require("github");
+
+ var github = new GitHubApi({
+ version: "3.0.0"
+ });
+
+ var admins = [];
+
+ github.orgs.getMembers({org: "cnodejs"},
+ function(err, members) {
+ for (i in members) {
+ var member_url = (members[i].url || '').replace('api.github.com/users', 'github.com');
+ admins.push(member_url);
+ }
+
+ if (admins.concat(config.admins).indexOf(user.t_url) !== -1) {
+ next();
+ } else {
+ res.send(401, {'status': 'fail', 'message': u.t_url + ' is unauthorized'});
+ }
+ });
};
app.get('/survey', survey.inviteTopics);

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit f38f4e5

Please sign in to comment.