mirror of https://github.com/calzoneman/sync.git
Bugfixes for last commit
- Fix race condition for login frame - Fix guest logins
This commit is contained in:
parent
3a7acd0526
commit
087f612b37
17
api.js
17
api.js
|
@ -126,6 +126,23 @@ function handleLogin(params, req, res) {
|
||||||
var name = params.name || "";
|
var name = params.name || "";
|
||||||
var pw = params.pw || "";
|
var pw = params.pw || "";
|
||||||
|
|
||||||
|
if(pw == "") {
|
||||||
|
if(!Auth.isRegistered(name)) {
|
||||||
|
sendJSON(res, {
|
||||||
|
success: true,
|
||||||
|
session: ""
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendJSON(res, {
|
||||||
|
success: false,
|
||||||
|
error: "That username is already taken"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var row = Auth.login(name, pw, session);
|
var row = Auth.login(name, pw, session);
|
||||||
if(row) {
|
if(row) {
|
||||||
sendJSON(res, {
|
sendJSON(res, {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const VERSION = "1.3.0";
|
const VERSION = "1.3.1";
|
||||||
|
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var Logger = require("./logger.js");
|
var Logger = require("./logger.js");
|
||||||
|
|
2
user.js
2
user.js
|
@ -398,7 +398,7 @@ User.prototype.login = function(name, pw, session) {
|
||||||
else {
|
else {
|
||||||
this.socket.emit("login", {
|
this.socket.emit("login", {
|
||||||
success: false,
|
success: false,
|
||||||
error: "Invalid username/password pair"
|
error: "Invalid session"
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ function initCallbacks() {
|
||||||
$("#loginform").css("display", "none");
|
$("#loginform").css("display", "none");
|
||||||
$("#logoutform").css("display", "");
|
$("#logoutform").css("display", "");
|
||||||
$("#loggedin").css("display", "");
|
$("#loggedin").css("display", "");
|
||||||
session = data.session;
|
session = data.session || "";
|
||||||
createCookie("sync_uname", uname, 7);
|
createCookie("sync_uname", uname, 7);
|
||||||
createCookie("sync_session", session, 7);
|
createCookie("sync_session", session, 7);
|
||||||
}
|
}
|
||||||
|
|
|
@ -863,7 +863,13 @@ function showLoginFrame() {
|
||||||
.css("height", "300px")
|
.css("height", "300px")
|
||||||
.css("margin", "0")
|
.css("margin", "0")
|
||||||
.appendTo(body);
|
.appendTo(body);
|
||||||
|
var timer = setInterval(function() {
|
||||||
|
frame[0].contentWindow.postMessage("cytube-syn", document.location);
|
||||||
|
}, 1000);
|
||||||
var respond = function(e) {
|
var respond = function(e) {
|
||||||
|
if(e.data == "cytube-ack") {
|
||||||
|
clearInterval(timer);
|
||||||
|
}
|
||||||
if(e.data.indexOf(":") == -1) {
|
if(e.data.indexOf(":") == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -874,8 +880,8 @@ function showLoginFrame() {
|
||||||
alert(data.error);
|
alert(data.error);
|
||||||
}
|
}
|
||||||
else if(data.success) {
|
else if(data.success) {
|
||||||
session = data.session;
|
session = data.session || "";
|
||||||
uname = data.uname;
|
uname = data.uname || "";
|
||||||
socket.emit("login", {
|
socket.emit("login", {
|
||||||
name: uname,
|
name: uname,
|
||||||
session: session
|
session: session
|
||||||
|
@ -900,9 +906,6 @@ function showLoginFrame() {
|
||||||
// their shit together
|
// their shit together
|
||||||
window.attachEvent("onmessage", respond);
|
window.attachEvent("onmessage", respond);
|
||||||
}
|
}
|
||||||
setTimeout(function() {
|
|
||||||
frame[0].contentWindow.postMessage("cytube-syn", document.location);
|
|
||||||
}, 1000);
|
|
||||||
var footer = $("<div/>").addClass("modal-footer").appendTo(modal);
|
var footer = $("<div/>").addClass("modal-footer").appendTo(modal);
|
||||||
modal.on("hidden", function() {
|
modal.on("hidden", function() {
|
||||||
modal.remove();
|
modal.remove();
|
||||||
|
|
|
@ -279,7 +279,6 @@ Media.prototype.initRTMP = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Media.prototype.update = function(data) {
|
Media.prototype.update = function(data) {
|
||||||
console.log(parseInt(data.currentTime / 60), parseInt(data.currentTime % 60));
|
|
||||||
if(data.id != this.id) {
|
if(data.id != this.id) {
|
||||||
if(data.currentTime < 0) {
|
if(data.currentTime < 0) {
|
||||||
data.currentTime = 0;
|
data.currentTime = 0;
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
var respond = function(e) {
|
var respond = function(e) {
|
||||||
if(e.data == "cytube-syn") {
|
if(e.data == "cytube-syn") {
|
||||||
source = e.source;
|
source = e.source;
|
||||||
|
source.postMessage("cytube-ack", document.location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.addEventListener("message", respond, false);
|
window.addEventListener("message", respond, false);
|
||||||
|
|
Loading…
Reference in New Issue