| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 | Router.configure({    loadingTemplate: 'loading',    notFoundTemplate: '404'});Router.onBeforeAction(function() {    var self = this;    var next = self.next;    var isMaintanance = Meteor.settings.public.maintenance;    if (Session.get("rTimeInterval") !== undefined) {        Meteor.clearInterval(Session.get("rTimeInterval"));        Session.set("rTimeInterval", undefined);    }    if(isMaintanance === true){        var user = Meteor.user();        if(user !== null && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")){            next();        } else {            this.render("maintenance");        }    } else {        if (Meteor.userId()) {            Meteor.call("isBanned", function(err, res) {                if (res) {                    self.render('banned');                } else {                    document.title = 'Musare';                    next();                }            });        } else {            next();        }    }});Router.route("/", {    template: "home",    name: "home"});Router.route("/login", {    action: function() {        var user = Meteor.user();        if (user === undefined || user === null) {            this.render("loginRegister");        } else {            this.redirect("/");        }    },    name: "login"});Router.route("/register", {    action: function() {        var user = Meteor.user();        if (user === undefined || user === null) {            this.render("loginRegister");        } else {            this.redirect("/");        }    },    name: "register"});Router.route("/settings", {    action: function() {        if (!Meteor.userId()) {            this.redirect("/");        } else {            this.render("settings");        }    },    name: "settings"});Router.route("/add", {    template: "addSong",    name: "addSong"});Router.route("/terms", {    template: "terms",    name: "terms"});Router.route("/contact", {    template: "contact",    name: "contact"});Router.route("/faq", {    template: "faq",    name: "faq"});Router.route("/privacy", {    template: "privacy",    name: "privacy"});Router.route("/feedback", {    template: "feedback",    name: "feedback"})//Router.route("/team", {//    template: "team",//    name: "team"//})Router.route("/news", {    template: "news",    name: "news"})Router.route("/project", {    template: "project",    name: "project"})/*Router.route("/donate", {    template: "donate", name: "donate"})*/Router.route("/admin", {    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("admin");        } else {            this.redirect("/");        }    },    name: "admin"});Router.route("/admin/songs", {    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("manageSongs");        } else {            this.redirect("/");        }    },    name: "manageSongs"});Router.route("/admin/queues", {    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("queues");        } else {            this.redirect("/");        }    },    name: "queues"});Router.route("/admin/alerts", {    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("alertsDashboard");        } else {            this.redirect("/");        }    },    name: "alertsDashboard"});Router.route("/u/:user", {    template: "profile",    name: "profile"});Router.route("/community/:name", {    waitOn: function() {        return [Meteor.subscribe("isModerator", Meteor.userId()), Meteor.subscribe("isAdmin", Meteor.userId()), Meteor.subscribe("community_station", this.params.name)];    },    action: function() {        var user = Meteor.users.findOne({});        var room = CommunityStations.findOne({name: this.params.name});        if (room !== undefined) {            if (                (room !== undefined)                    &&                (                    (room.privacy === "private" && user !== undefined && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")) ||                    (user !== undefined && user.profile !== undefined && room.allowed.includes(Meteor.userId())) ||                    room.privacy !== "private" ||                    room.owner === Meteor.userId())                ) {                this.render("communityStation");            } else {                this.redirect("/");            }        } else {            this.render("404");        }    },    name: "communityStation"});Router.route("/:type", {    waitOn: function() {        return [Meteor.subscribe("songsType", this.params.type), Meteor.subscribe("isModerator", Meteor.userId()), Meteor.subscribe("isAdmin", Meteor.userId()), Meteor.subscribe("rooms")];    },    action: function() {        var user = Meteor.users.findOne({});        var room = Rooms.findOne({type: this.params.type});        if (room !== undefined) {            if ((room.private === true && user !== undefined && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")) || room.private === false) {                Session.set("type", this.params.type);                this.render("room");            } else {                this.redirect("/");            }        } else {            this.render("404");        }    },    name: "station"});Router.route("/:type/manage", {    waitOn: function() {        return [Meteor.subscribe("isModerator", Meteor.userId()), Meteor.subscribe("isAdmin", Meteor.userId())];    },    action: function() {        var user = Meteor.users.findOne({});        var room = Rooms.findOne({type: this.params.type});        if (room !== undefined && user !== undefined && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")) {            this.render("manageStation");        } else {            this.redirect("/");        }    },    name: "manageStation"});
 |