|
@@ -22,6 +22,34 @@ Deps.autorun(function() {
|
|
|
Meteor.subscribe("userData", Meteor.userId());
|
|
|
});
|
|
|
|
|
|
+var ban_interval = Meteor.setInterval(function() {
|
|
|
+ var userId = Meteor.userId();
|
|
|
+ if (userId !== undefined) {
|
|
|
+ var userData = Meteor.user();
|
|
|
+ if (localStorage.getItem("banned") === "true") {
|
|
|
+ if (userData !== undefined && userData !== null && userData.punishments !== undefined && userData.punishments.ban !== undefined) {
|
|
|
+ var ban = userData.punishments.ban;
|
|
|
+ if (new Date(ban.bannedUntil).getTime() <= new Date().getTime()) {
|
|
|
+ Meteor.call("isBanned", function(err, res) {
|
|
|
+ if (res === false) {
|
|
|
+ localStorage.setItem("banned", false);
|
|
|
+ Meteor._reload.reload();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ localStorage.setItem("banned", false);
|
|
|
+ Meteor._reload.reload();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (userData !== undefined && userData !== null && userData.punishments !== undefined && userData.punishments.ban !== undefined) {
|
|
|
+ localStorage.setItem("banned", true);
|
|
|
+ Meteor._reload.reload();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}, 1000);
|
|
|
+
|
|
|
var minterval;
|
|
|
var hpSound = undefined;
|
|
|
var songsArr = [];
|
|
@@ -201,7 +229,7 @@ Template.header.helpers({
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
Template.header.events({
|
|
@@ -214,6 +242,33 @@ Template.header.events({
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+Template.register.onCreated(function() {
|
|
|
+ Accounts.onLoginFailure(function() {
|
|
|
+ var errAlert = $('<div style="margin-bottom: 0" class="alert alert-danger" role="alert"><strong>Oh Snap!</strong> Something went wrong when trying to register with GitHub. Maybe an account with that username already exists?</div>');
|
|
|
+ $(".landing").before(errAlert);
|
|
|
+ Meteor.setTimeout(function() {
|
|
|
+ errAlert.fadeOut(5000, function() {
|
|
|
+ errAlert.remove();
|
|
|
+ });
|
|
|
+ }, 10000);
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+Template.login.onCreated(function() {
|
|
|
+ Session.set("github", true);
|
|
|
+ Accounts.onLoginFailure(function() {
|
|
|
+ if (Session.get("github") === true) {
|
|
|
+ var errAlert = $('<div style="margin-bottom: 0" class="alert alert-danger" role="alert"><strong>Oh Snap!</strong> Something went wrong when trying to log in with GitHub.</div>');
|
|
|
+ $(".landing").before(errAlert);
|
|
|
+ Meteor.setTimeout(function() {
|
|
|
+ errAlert.fadeOut(5000, function() {
|
|
|
+ errAlert.remove();
|
|
|
+ });
|
|
|
+ }, 10000);
|
|
|
+ }
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
Template.register.events({
|
|
|
"submit form": function(e){
|
|
|
e.preventDefault();
|
|
@@ -226,11 +281,13 @@ Template.register.events({
|
|
|
|
|
|
if (err) {
|
|
|
console.log(err);
|
|
|
- var errAlert = $('<div class="alert alert-danger" role="alert"><strong>Oh Snap!</strong> ' + err.reason + '</div>');
|
|
|
- $("#login").after(errAlert);
|
|
|
- errAlert.fadeOut(20000, function() {
|
|
|
- errAlert.remove();
|
|
|
- });
|
|
|
+ var errAlert = $('<div style="margin-bottom: 0" class="alert alert-danger" role="alert"><strong>Oh Snap!</strong> ' + err.reason + '</div>');
|
|
|
+ $(".landing").before(errAlert);
|
|
|
+ Meteor.setTimeout(function() {
|
|
|
+ errAlert.fadeOut(5000, function() {
|
|
|
+ errAlert.remove();
|
|
|
+ });
|
|
|
+ }, 5000);
|
|
|
} else {
|
|
|
Meteor.loginWithPassword(username, password);
|
|
|
Accounts.onLogin(function(){
|
|
@@ -248,47 +305,28 @@ Template.register.events({
|
|
|
Template.login.events({
|
|
|
"submit form": function(e){
|
|
|
e.preventDefault();
|
|
|
+ Session.set("github", false);
|
|
|
var username = e.target.loginUsername.value;
|
|
|
var password = e.target.loginPassword.value;
|
|
|
- Meteor.loginWithPassword(username, password);
|
|
|
- Accounts.onLogin(function(){
|
|
|
- window.location.href = "/";
|
|
|
- })
|
|
|
- Accounts.onLoginFailure(function(){
|
|
|
- $("#login-form input").css("background-color","indianred");
|
|
|
- $("#login-form input").on("click",function(){
|
|
|
- $("#login-form input").css({
|
|
|
- "-webkit-appearance": "none",
|
|
|
- " -moz-appearance": "none",
|
|
|
- " appearance": "none",
|
|
|
- "outline": "0",
|
|
|
- "border": "1px solid rgba(255, 255, 255, 0.4)",
|
|
|
- "background-color": "rgba(255, 255, 255, 0.2)",
|
|
|
- "width": "304px",
|
|
|
- "border-radius": "3px",
|
|
|
- "padding": "10px 15px",
|
|
|
- "margin": "0 auto 10px auto",
|
|
|
- "display": "block",
|
|
|
- "text-align": "center",
|
|
|
- "font-size": "18px",
|
|
|
- "color": "white",
|
|
|
- "-webkit-transition-duration": "0.25s",
|
|
|
- " transition-duration": "0.25s",
|
|
|
- "font-weight": "300"
|
|
|
- });
|
|
|
- $("#login-form input:focus").css({
|
|
|
- "width": "354px",
|
|
|
- "color": "white"
|
|
|
- })
|
|
|
- $("#login-form input").on("blur", function(){
|
|
|
- $(this).css("width", "304px");
|
|
|
- })
|
|
|
- })
|
|
|
+ Meteor.loginWithPassword(username, password, function(err) {
|
|
|
+ if (err) {
|
|
|
+ var errAlert = $('<div style="margin-bottom: 0" class="alert alert-danger" role="alert"><strong>Oh Snap!</strong> ' + err.reason + '</div>');
|
|
|
+ $(".landing").before(errAlert);
|
|
|
+ Meteor.setTimeout(function() {
|
|
|
+ errAlert.fadeOut(5000, function() {
|
|
|
+ errAlert.remove();
|
|
|
+ });
|
|
|
+ }, 5000);
|
|
|
+ } else {
|
|
|
+ window.location.href = "/";
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
|
|
|
"click #github-login": function(){
|
|
|
- Meteor.loginWithGithub({loginStyle: "redirect"});
|
|
|
+ Meteor.loginWithGithub({loginStyle: "redirect"}, function(err, res) {
|
|
|
+ console.log(err, res);
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -305,6 +343,20 @@ Template.dashboard.helpers({
|
|
|
} else {
|
|
|
return {};
|
|
|
}
|
|
|
+ },
|
|
|
+ isAdmin: function() {
|
|
|
+ if (Meteor.user() && Meteor.user().profile) {
|
|
|
+ return Meteor.user().profile.rank === "admin";
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ isModerator: function() {
|
|
|
+ if (Meteor.user() && Meteor.user().profile && (Meteor.user().profile.rank === "admin" || Meteor.user().profile.rank === "moderator")) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -723,9 +775,7 @@ Template.banned.onCreated(function() {
|
|
|
rTimeInterval = Meteor.setInterval(function() {
|
|
|
Session.set("time", new Date().getTime());
|
|
|
}, 10000);
|
|
|
- Meteor.subscribe("ownBan", Meteor.userId(), function() {
|
|
|
- Session.set("ban", Meteor.user().punishments.ban);
|
|
|
- });
|
|
|
+ Session.set("ban", Meteor.user().punishments.ban);
|
|
|
});
|
|
|
|
|
|
Template.registerHelper("rtime", function(date) {
|