diff --git a/api.js b/api.js
index 55a72e9c..4ec207cc 100644
--- a/api.js
+++ b/api.js
@@ -131,18 +131,17 @@ module.exports = function (Server) {
if(!pw && !session) {
res.jsonp({
success: false,
- error_code: "need_pw_or_session",
error: "You must provide a password"
});
return;
}
var row = Auth.login(name, pw, session);
+ console.log(row);
if(!row) {
if(session && !pw) {
res.jsonp({
success: false,
- error_code: "invalid_session",
error: "Session expired"
});
return;
@@ -151,7 +150,6 @@ module.exports = function (Server) {
"invalid_password");
res.jsonp({
success: false,
- error_code: "invalid_password",
error: "Provided username/password pair is invalid"
});
return;
diff --git a/www/assets/js/account.js b/www/assets/js/account.js
index 1f1d8fe0..125c48a6 100644
--- a/www/assets/js/account.js
+++ b/www/assets/js/account.js
@@ -11,17 +11,16 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
var uname = readCookie("cytube_uname") || "";
var session = readCookie("cytube_session") || "";
-var api = WEB_URL + "/api/json/";
var loggedin = false;
if(uname && session) {
- var loginstr = "name=" + encodeURIComponent(uname)
- + "&session=" + session;
- var url = api + "login?" + loginstr + "&callback=?";
- $.getJSON(url, function(data) {
- if(data.success) {
+ var data = {
+ name: uname,
+ session: session
+ };
+ $.post(WEB_URL + "/api/login?callback=?", data, function (data) {
+ if(data.success)
onLogin();
- }
});
}
@@ -57,7 +56,8 @@ $("#email").click(makeTabCallback("#email", "#changeemailpane"));
$("#profile").click(makeTabCallback("#profile", "#profilepane"));
$("#profile").click(function() {
if(uname != "") {
- $.getJSON(api + "getprofile?name=" + encodeURIComponent(uname) + "&callback=?", function(data) {
+ $.getJSON(WEB_URL+"/api/users/"+uname+"/profile?callback=?",
+ function (data) {
if(data.success) {
$("#profiletext").val(data.profile_text);
$("#profileimg").val(data.profile_image);
@@ -82,8 +82,10 @@ $("#channels").click(function () {
return;
}
- $.getJSON(api + "listuserchannels?name=" + encodeURIComponent(uname) +
- "&session=" + session + "&callback=?", function(data) {
+ var auth = "name=" + encodeURIComponent(uname) + "&session=" +
+ encodeURIComponent(session);
+ $.getJSON(WEB_URL+"/api/account/mychannels?"+auth+"&callback=?",
+ function (data) {
$("#channellist tbody").remove();
data.channels.forEach(function (chan) {
var tr = $("
").appendTo($("#channellist"));
@@ -134,12 +136,12 @@ $("#registerbtn").click(function() {
}
// Input valid, try registering
- var url = api + "register?" + [
- "name=" + encodeURIComponent(name),
- "pw=" + encodeURIComponent(pw)
- ].join("&") + "&callback=?";
-
- $.getJSON(url, function(data) {
+ var data = {
+ name: name,
+ pw: pw
+ };
+
+ $.pos(WEB_URL + "/api/register?callback=?", data, function (data) {
if(data.success) {
uname = name;
session = data.session;
@@ -170,10 +172,11 @@ $("#loginbtn").click(function() {
return;
}
uname = $("#loginusername").val();
- var loginstr = "name=" + encodeURIComponent(uname)
- + "&pw=" + encodeURIComponent($("#loginpw").val());
- var url = api + "login?" + loginstr + "&callback=?";
- $.getJSON(url, function(data) {
+ var data = {
+ name: uname,
+ pw: $("#loginpw").val()
+ };
+ $.getJSON(WEB_URL+"/api/login?callback=?", data, function(data) {
if(data.success) {
session = data.session;
onLogin();
@@ -230,12 +233,13 @@ $("#cpwbtn").click(function() {
}
// Input valid, try changing password
- var url = api + "changepass?" + [
- "name=" + encodeURIComponent(name),
- "oldpw=" + encodeURIComponent(oldpw),
- "newpw=" + encodeURIComponent(newpw)
- ].join("&") + "&callback=?";
- $.getJSON(url, function(data) {
+ var data = {
+ name: name,
+ oldpw: oldpw,
+ newpw: newpw
+ };
+ $.post(WEB_URL + "/api/account/passwordchange?callback=?", data,
+ function (data) {
if(data.success) {
$("").addClass("alert alert-success")
.text("Password changed.")
@@ -266,7 +270,7 @@ $("#cebtn").click(function() {
return;
}
- if(!email.match(/^[a-z0-9_\.]+@[a-z0-9_\.]+[a-z]+$/)) {
+ if(!email.match(/^[\w_\.]+@[\w_\.]+[a-zA-Z]+$/)) {
$("").addClass("alert alert-error")
.text("Invalid email")
.insertAfter($("#ceemail").parent().parent());
@@ -282,12 +286,13 @@ $("#cebtn").click(function() {
return;
}
- var url = api + "setemail?" + [
- "name=" + encodeURIComponent(name),
- "pw=" + encodeURIComponent(pw),
- "email=" + encodeURIComponent(email)
- ].join("&") + "&callback=?";
- $.getJSON(url, function(data) {
+ var data = {
+ name: name,
+ pw: pw,
+ email: email
+ };
+ $.post(WEB_URL + "/api/account/email?callback=?", data,
+ function (data) {
if(data.success) {
$("").addClass("alert alert-success")
.text("Email updated")
@@ -312,11 +317,12 @@ $("#rpbtn").click(function() {
var name = $("#rpusername").val();
var email = $("#rpemail").val();
- var url = api + "resetpass?" + [
- "name=" + encodeURIComponent(name),
- "email=" + encodeURIComponent(email)
- ].join("&") + "&callback=?";
- $.getJSON(url, function(data) {
+ var data = {
+ name: name,
+ email: email
+ };
+ $.post(WEB_URL + "/api/account/passwordreset?callback=?", data,
+ function (data) {
$("#rpbtn").text("Send Reset");
if(data.success) {
$("").addClass("alert alert-success")
@@ -336,20 +342,16 @@ $("#profilesave").click(function() {
$("#profilepane").find(".alert-error").remove();
$("#profilepane").find(".alert-success").remove();
var img = $("#profileimg").val();
- /*
- img = escape(img).replace(/\//g, "%2F")
- .replace(/&/g, "%26")
- .replace(/=/g, "%3D")
- .replace(/\?/g, "%3F");
- */
- var url = api + "setprofile?" + [
- "name=" + encodeURIComponent(uname),
- "session=" + session,
- "profile_image=" + encodeURIComponent(img),
- "profile_text=" + encodeURIComponent($("#profiletext").val())
- ].join("&") + "&callback=?";
+ var text = $("#profiletext").val();
+ var data = {
+ name: uname,
+ session: session,
+ profile_image: img,
+ profile_text: text
+ };
- $.getJSON(url, function(data) {
+ $.post(WEB_URL+"/api/account/profile?callback=?", data,
+ function (data) {
if(data.success) {
$("").addClass("alert alert-success")
.text("Profile updated.")
diff --git a/www/channel-new.html b/www/channel-new.html
deleted file mode 100644
index 228e302b..00000000
--- a/www/channel-new.html
+++ /dev/null
@@ -1,200 +0,0 @@
-
-
-
-
- CyTube
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
CyTube
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Nothing playing
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Show Playlist Manager
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Show Playlist Controls
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/www/channelwidget.html b/www/channelwidget.html
deleted file mode 100644
index a4e918b1..00000000
--- a/www/channelwidget.html
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
- CyTube
-
-
-
-
-
-
-
- Channel |
- Connected |
- Playing |
-
-
-
-
-
-
-
-
-
-
diff --git a/www/index.html b/www/index.html
index f2ae309e..1cf512fa 100644
--- a/www/index.html
+++ b/www/index.html
@@ -130,7 +130,8 @@
return entry;
}
function refresh() {
- $.getJSON(WEB_URL+"/api/json/listloaded?filter=public&callback=?", function(data) {
+ $.getJSON(WEB_URL+"/api/allchannels/public?callback=?",
+ function(data) {
$("#channeldata").find("tbody").remove();
data.sort(function(a, b) {
var x = a.usercount;
diff --git a/www/login.html b/www/login.html
index 02fe6b72..d255cfa8 100644
--- a/www/login.html
+++ b/www/login.html
@@ -66,9 +66,11 @@
window.addEventListener("message", respond, false);
$("#login").click(function() {
- var u = encodeURIComponent($("#username").val());
- var p = encodeURIComponent($("#pw").val());
- $.getJSON(WEB_URL+"/api/json/login?name="+u+"&pw="+p+"&callback=?", function(data) {
+ var data = {
+ name: $("#username").val(),
+ pw: $("#pw").val()
+ };
+ $.post(WEB_URL+"/api/login", data, function (data) {
data.uname = $("#username").val();
source.postMessage("cytube-login:"+JSON.stringify(data), document.location);
});
diff --git a/www/reset.html b/www/reset.html
index 76aaf280..a9f9529f 100644
--- a/www/reset.html
+++ b/www/reset.html
@@ -71,7 +71,8 @@
hash = loc.substring(loc.indexOf("?") + 1);
})();
- var url = WEB_URL+"/api/json/recoverpw?hash="+hash+"&callback=?";
+ var url = WEB_URL+"/api/account/passwordrecover?hash="+hash+
+ "&callback=?";
$.getJSON(url, function(data) {
if(data.success) {
$("").addClass("alert alert-success")