Explorar o código

added redirect verification for locked rooms

Akira %!s(int64=9) %!d(string=hai) anos
pai
achega
3c623f4770
Modificáronse 1 ficheiros con 11 adicións e 1 borrados
  1. 11 1
      app/client/routes.js

+ 11 - 1
app/client/routes.js

@@ -131,7 +131,17 @@ Router.route("/admin/alerts", {
 });
 
 Router.route("/:type", {
-    template: "room"
+    waitOn: function() {
+        return [Meteor.subscribe("isModerator", Meteor.userId()), Meteor.subscribe("isAdmin", Meteor.userId())];
+    },
+    action: function() {
+        var user = Meteor.users.findOne({});
+        if (user !== undefined && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")) {
+            this.render("room");
+        } else {
+            this.redirect("/");
+        }
+    }
 });
 
 Router.route("/u/:user", {