routes.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. Router.configure({
  2. loadingTemplate: 'loading'
  3. });
  4. Router.onBeforeAction(function() {
  5. var self = this;
  6. var next = self.next;
  7. if (Meteor.userId()) {
  8. Meteor.call("isBanned", function(err, res) {
  9. if (res) {
  10. self.render('banned');
  11. pause();
  12. } else {
  13. next();
  14. }
  15. });
  16. } else {
  17. next();
  18. }
  19. });
  20. Router.route("/", {
  21. template: "home"
  22. });
  23. Router.route("/login", {
  24. action: function() {
  25. var user = Meteor.user();
  26. if (user === undefined || user === null) {
  27. this.render("login");
  28. } else {
  29. this.redirect("/");
  30. }
  31. }
  32. });
  33. Router.route("/signup", {
  34. action: function() {
  35. var user = Meteor.user();
  36. if (user === undefined || user === null) {
  37. this.render("register");
  38. } else {
  39. this.redirect("/");
  40. }
  41. }
  42. });
  43. Router.route("/settings", {
  44. action: function() {
  45. if (!Meteor.userId()) {
  46. this.redirect("/");
  47. } else {
  48. this.render("settings");
  49. }
  50. }
  51. });
  52. Router.route("/terms", {
  53. template: "terms"
  54. });
  55. Router.route("/contact", {
  56. template: "contact"
  57. });
  58. Router.route("/faq", {
  59. template: "faq"
  60. });
  61. Router.route("/privacy", {
  62. template: "privacy"
  63. });
  64. Router.route("/about", {
  65. template: "about"
  66. });
  67. Router.route("/admin", {
  68. waitOn: function() {
  69. return [Meteor.subscribe("isModerator", Meteor.userId()), Meteor.subscribe("isAdmin", Meteor.userId())];
  70. },
  71. action: function() {
  72. var user = Meteor.users.findOne({});
  73. if (user !== undefined && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")) {
  74. this.render("admin");
  75. } else {
  76. this.redirect("/");
  77. }
  78. }
  79. });
  80. Router.route("/admin/stations", {
  81. waitOn: function() {
  82. return [Meteor.subscribe("isModerator", Meteor.userId()), Meteor.subscribe("isAdmin", Meteor.userId())];
  83. },
  84. action: function() {
  85. var user = Meteor.users.findOne({});
  86. if (user !== undefined && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")) {
  87. this.render("stations");
  88. } else {
  89. this.redirect("/");
  90. }
  91. }
  92. });
  93. Router.route("/admin/queues", {
  94. waitOn: function() {
  95. return [Meteor.subscribe("isModerator", Meteor.userId()), Meteor.subscribe("isAdmin", Meteor.userId())];
  96. },
  97. action: function() {
  98. var user = Meteor.users.findOne({});
  99. if (user !== undefined && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")) {
  100. this.render("queues");
  101. } else {
  102. this.redirect("/");
  103. }
  104. }
  105. });
  106. Router.route("/admin/alerts", {
  107. waitOn: function() {
  108. return [Meteor.subscribe("isModerator", Meteor.userId()), Meteor.subscribe("isAdmin", Meteor.userId())];
  109. },
  110. action: function() {
  111. var user = Meteor.users.findOne({});
  112. if (user !== undefined && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")) {
  113. this.render("alertsDashboard");
  114. } else {
  115. this.redirect("/");
  116. }
  117. }
  118. });
  119. Router.route("/:type", {
  120. template: "room"
  121. });
  122. Router.route("/u/:user", {
  123. template: "profile"
  124. });