Fixes
This commit is contained in:
parent
c9b5254f24
commit
08a46f5e00
20
channel.js
20
channel.js
|
|
@ -119,14 +119,6 @@ var Channel = function(name, Server) {
|
||||||
|
|
||||||
Server.db.loadChannelData(self, function () {
|
Server.db.loadChannelData(self, function () {
|
||||||
self.dbloaded = true;
|
self.dbloaded = true;
|
||||||
// If the channel is empty and isn't registered, the first person
|
|
||||||
// gets ownership of the channel (temporarily)
|
|
||||||
if(self.users.length == 1 && !self.registered) {
|
|
||||||
var user = self.users[0];
|
|
||||||
user.rank = (user.rank < Rank.Owner) ? 10 : user.rank;
|
|
||||||
self.broadcastUserUpdate(user);
|
|
||||||
user.socket.emit("channelNotRegistered");
|
|
||||||
}
|
|
||||||
if(self.registered) {
|
if(self.registered) {
|
||||||
self.loadDump();
|
self.loadDump();
|
||||||
}
|
}
|
||||||
|
|
@ -710,12 +702,6 @@ Channel.prototype.userJoin = function(user) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the channel is empty and isn't registered, the first person
|
|
||||||
// gets ownership of the channel (temporarily)
|
|
||||||
if(this.dbloaded && this.users.length == 0 && !this.registered) {
|
|
||||||
user.rank = (user.rank < Rank.Owner) ? 10 : user.rank;
|
|
||||||
user.socket.emit("channelNotRegistered");
|
|
||||||
}
|
|
||||||
this.users.push(user);
|
this.users.push(user);
|
||||||
this.broadcastVoteskipUpdate();
|
this.broadcastVoteskipUpdate();
|
||||||
if(user.name != "") {
|
if(user.name != "") {
|
||||||
|
|
@ -953,6 +939,12 @@ Channel.prototype.broadcastUsercount = function() {
|
||||||
|
|
||||||
Channel.prototype.broadcastNewUser = function(user) {
|
Channel.prototype.broadcastNewUser = function(user) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
// If the channel is empty and isn't registered, the first person
|
||||||
|
// gets ownership of the channel (temporarily)
|
||||||
|
if(self.dbloaded && self.users.length == 1 && !self.registered) {
|
||||||
|
user.rank = (user.rank < Rank.Owner) ? 10 : user.rank;
|
||||||
|
user.socket.emit("channelNotRegistered");
|
||||||
|
}
|
||||||
self.server.db.listAliases(user.ip, function (err, aliases) {
|
self.server.db.listAliases(user.ip, function (err, aliases) {
|
||||||
if(err) {
|
if(err) {
|
||||||
aliases = [];
|
aliases = [];
|
||||||
|
|
|
||||||
|
|
@ -747,6 +747,11 @@ Database.prototype.userLogin = function (name, pw, session, callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(row.session_hash) {
|
||||||
|
callback(null, row);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self.createLoginSession(name, function (err, hash) {
|
self.createLoginSession(name, function (err, hash) {
|
||||||
if(err) {
|
if(err) {
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
|
|
@ -790,6 +795,7 @@ Database.prototype.userLoginPassword = function (name, pw, callback) {
|
||||||
if(valid) {
|
if(valid) {
|
||||||
// For security, erase the password field before returning
|
// For security, erase the password field before returning
|
||||||
delete row["pw"];
|
delete row["pw"];
|
||||||
|
row.session_hash = "";
|
||||||
callback(null, row);
|
callback(null, row);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -809,6 +815,7 @@ Database.prototype.userLoginPassword = function (name, pw, callback) {
|
||||||
|
|
||||||
// Remove password field before returning
|
// Remove password field before returning
|
||||||
delete row["pw"];
|
delete row["pw"];
|
||||||
|
row.session_hash = "";
|
||||||
callback(null, row);
|
callback(null, row);
|
||||||
} else {
|
} else {
|
||||||
callback("Invalid username/password combination", null);
|
callback("Invalid username/password combination", null);
|
||||||
|
|
|
||||||
11
user.js
11
user.js
|
|
@ -475,7 +475,6 @@ User.prototype.initCallbacks = function() {
|
||||||
self.server.db.saveUserPlaylist(pl, self.name, data.name,
|
self.server.db.saveUserPlaylist(pl, self.name, data.name,
|
||||||
function (err, res) {
|
function (err, res) {
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log(typeof err);
|
|
||||||
self.socket.emit("savePlaylist", {
|
self.socket.emit("savePlaylist", {
|
||||||
success: false,
|
success: false,
|
||||||
error: err
|
error: err
|
||||||
|
|
@ -628,7 +627,7 @@ User.prototype.login = function(name, pw, session) {
|
||||||
} else {
|
} else {
|
||||||
self.server.db.userLogin(name, pw, session, function (err, row) {
|
self.server.db.userLogin(name, pw, session, function (err, row) {
|
||||||
if(err) {
|
if(err) {
|
||||||
self.server.actionlog.record(self.ip, self.name, "login-failure");
|
self.server.actionlog.record(self.ip, name, "login-failure");
|
||||||
self.socket.emit("login", {
|
self.socket.emit("login", {
|
||||||
success: false,
|
success: false,
|
||||||
error: err
|
error: err
|
||||||
|
|
@ -637,7 +636,7 @@ User.prototype.login = function(name, pw, session) {
|
||||||
}
|
}
|
||||||
if(self.channel != null) {
|
if(self.channel != null) {
|
||||||
for(var i = 0; i < self.channel.users.length; i++) {
|
for(var i = 0; i < self.channel.users.length; i++) {
|
||||||
if(self.channel.users[i].name == name) {
|
if(self.channel.users[i].name.toLowerCase() == name.toLowerCase()) {
|
||||||
self.channel.kick(self.channel.users[i], "Duplicate login");
|
self.channel.kick(self.channel.users[i], "Duplicate login");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -667,11 +666,11 @@ User.prototype.login = function(name, pw, session) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(self.channel !== null) {
|
if(self.channel !== null) {
|
||||||
self.channel.getRank(self.name, function (err, rank) {
|
self.channel.getRank(name, function (err, rank) {
|
||||||
if(!err && rank > self.global_rank)
|
if(!err)
|
||||||
self.rank = rank;
|
self.rank = rank;
|
||||||
else
|
else
|
||||||
self.rank = self.global_rank
|
self.rank = self.global_rank;
|
||||||
afterRankLookup();
|
afterRankLookup();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,10 @@ if(uname && session) {
|
||||||
session: session
|
session: session
|
||||||
};
|
};
|
||||||
postJSON(WEB_URL + "/api/login?callback=?", data, function (data) {
|
postJSON(WEB_URL + "/api/login?callback=?", data, function (data) {
|
||||||
|
console.log(data);
|
||||||
if(data.success)
|
if(data.success)
|
||||||
onLogin();
|
onLogin();
|
||||||
}, "jsonp");
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLogin() {
|
function onLogin() {
|
||||||
|
|
@ -182,7 +183,7 @@ $("#registerbtn").click(function() {
|
||||||
.text(data.error)
|
.text(data.error)
|
||||||
.insertBefore($("#registerpane form"));
|
.insertBefore($("#registerpane form"));
|
||||||
}
|
}
|
||||||
}, "jsonp");
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#loginbtn").click(function() {
|
$("#loginbtn").click(function() {
|
||||||
|
|
@ -217,7 +218,7 @@ $("#loginbtn").click(function() {
|
||||||
.text(data.error)
|
.text(data.error)
|
||||||
.insertBefore($("#loginpane form"));
|
.insertBefore($("#loginpane form"));
|
||||||
}
|
}
|
||||||
}, "jsonp");
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#cpwbtn").click(function() {
|
$("#cpwbtn").click(function() {
|
||||||
|
|
@ -279,7 +280,7 @@ $("#cpwbtn").click(function() {
|
||||||
.text(data.error)
|
.text(data.error)
|
||||||
.insertBefore($("#changepwpane form"));
|
.insertBefore($("#changepwpane form"));
|
||||||
}
|
}
|
||||||
}, "jsonp");
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#cebtn").click(function() {
|
$("#cebtn").click(function() {
|
||||||
|
|
@ -332,7 +333,7 @@ $("#cebtn").click(function() {
|
||||||
.text(data.error)
|
.text(data.error)
|
||||||
.insertBefore($("#changeemailpane form"));
|
.insertBefore($("#changeemailpane form"));
|
||||||
}
|
}
|
||||||
}, "jsonp");
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -360,7 +361,7 @@ $("#rpbtn").click(function() {
|
||||||
.text(data.error)
|
.text(data.error)
|
||||||
.insertBefore($("#pwresetpane form"));
|
.insertBefore($("#pwresetpane form"));
|
||||||
}
|
}
|
||||||
}, "jsonp");
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -388,7 +389,7 @@ $("#profilesave").click(function() {
|
||||||
.text(data.error)
|
.text(data.error)
|
||||||
.insertBefore($("#profilepane form"));
|
.insertBefore($("#profilepane form"));
|
||||||
}
|
}
|
||||||
}, "jsonp");
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#login").click(function() {
|
$("#login").click(function() {
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,30 @@
|
||||||
<script src="assets/js/jquery.js" type="text/javascript"></script>
|
<script src="assets/js/jquery.js" type="text/javascript"></script>
|
||||||
<script src="assets/js/iourl.js" type="text/javascript"></script>
|
<script src="assets/js/iourl.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
/*
|
||||||
|
So, it turns out that $.post causes Firefox to use a GET request
|
||||||
|
on cross-site requests. What the hell? I'd understand if they just
|
||||||
|
made it error instead, but why give me chicken tenders if I ordered a
|
||||||
|
cheeseburger and act like everything's peachy?
|
||||||
|
*/
|
||||||
|
function postJSON(url, data, callback) {
|
||||||
|
$.ajax(url, {
|
||||||
|
method: "POST",
|
||||||
|
crossDomain: true,
|
||||||
|
data: data,
|
||||||
|
success: function (data) {
|
||||||
|
try {
|
||||||
|
data = data.substring(data.indexOf("{"));
|
||||||
|
data = data.substring(0, data.lastIndexOf("}") + 1);
|
||||||
|
data = JSON.parse(data);
|
||||||
|
callback(data);
|
||||||
|
} catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dataType: "text"
|
||||||
|
});
|
||||||
|
}
|
||||||
function readCookie(name) {
|
function readCookie(name) {
|
||||||
var nameEQ = name + "=";
|
var nameEQ = name + "=";
|
||||||
var ca = document.cookie.split(";");
|
var ca = document.cookie.split(";");
|
||||||
|
|
@ -70,10 +94,10 @@
|
||||||
name: $("#username").val(),
|
name: $("#username").val(),
|
||||||
pw: $("#pw").val()
|
pw: $("#pw").val()
|
||||||
};
|
};
|
||||||
$.post(WEB_URL+"/api/login", data, function (data) {
|
postJSON(WEB_URL+"/api/login", data, function (data) {
|
||||||
data.uname = $("#username").val();
|
data.uname = $("#username").val();
|
||||||
source.postMessage("cytube-login:"+JSON.stringify(data), document.location);
|
source.postMessage("cytube-login:"+JSON.stringify(data), document.location);
|
||||||
}, "jsonp");
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue