浏览代码

added redirect verification for locked rooms

Akira 9 年之前
父节点
当前提交
3c623f4770
共有 1 个文件被更改,包括 11 次插入1 次删除
  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", {