Change behavior for MySQL fail
This commit is contained in:
parent
e902a8074a
commit
728f23a05b
BIN
.header.js.swp
BIN
.header.js.swp
Binary file not shown.
BIN
.server.js.swp
BIN
.server.js.swp
Binary file not shown.
9
auth.js
9
auth.js
|
@ -15,7 +15,8 @@ exports.isRegistered = function(name) {
|
||||||
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
||||||
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
||||||
if(!db.connectedSync()) {
|
if(!db.connectedSync()) {
|
||||||
throw "[](/abchaos) MySQL Connection Failed";
|
console.log("MySQL Connection Failed");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
var query = 'SELECT * FROM registrations WHERE uname="{}"'
|
var query = 'SELECT * FROM registrations WHERE uname="{}"'
|
||||||
.replace(/\{\}/, name);
|
.replace(/\{\}/, name);
|
||||||
|
@ -44,7 +45,8 @@ exports.register = function(name, sha256) {
|
||||||
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
||||||
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
||||||
if(!db.connectedSync()) {
|
if(!db.connectedSync()) {
|
||||||
throw "[](/abchaos) MySQL Connection Failed";
|
console.log("MySQL Connection Failed");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
var query = 'INSERT INTO registrations VALUES (NULL, "{1}", "{2}", 0)'
|
var query = 'INSERT INTO registrations VALUES (NULL, "{1}", "{2}", 0)'
|
||||||
.replace(/\{1\}/, name)
|
.replace(/\{1\}/, name)
|
||||||
|
@ -60,7 +62,8 @@ exports.login = function(name, sha256) {
|
||||||
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
||||||
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
||||||
if(!db.connectedSync()) {
|
if(!db.connectedSync()) {
|
||||||
throw "[](/abchaos) MySQL Connection Failed";
|
console.log("MySQL Connection Failed");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
var query = 'SELECT * FROM registrations WHERE uname="{1}" AND pw="{2}"'
|
var query = 'SELECT * FROM registrations WHERE uname="{1}" AND pw="{2}"'
|
||||||
.replace(/\{1\}/, name)
|
.replace(/\{1\}/, name)
|
||||||
|
|
15
channel.js
15
channel.js
|
@ -35,7 +35,8 @@ Channel.prototype.loadMysql = function() {
|
||||||
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
||||||
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
||||||
if(!db.connectedSync()) {
|
if(!db.connectedSync()) {
|
||||||
throw "[](/abchaos) MySQL Connection Failed";
|
console.log("MySQL Connection Failed");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
// Check if channel exists
|
// Check if channel exists
|
||||||
var query = 'SELECT * FROM channels WHERE name="{}"'
|
var query = 'SELECT * FROM channels WHERE name="{}"'
|
||||||
|
@ -67,7 +68,8 @@ Channel.prototype.createTables = function() {
|
||||||
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
||||||
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
||||||
if(!db.connectedSync()) {
|
if(!db.connectedSync()) {
|
||||||
throw "[](/abchaos) MySQL Connection Failed";
|
console.log("MySQL Connection Failed");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
// Create library table
|
// Create library table
|
||||||
var query= "CREATE TABLE `chan_{}_library` \
|
var query= "CREATE TABLE `chan_{}_library` \
|
||||||
|
@ -107,7 +109,8 @@ Channel.prototype.getRank = function(name) {
|
||||||
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
||||||
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
||||||
if(!db.connectedSync()) {
|
if(!db.connectedSync()) {
|
||||||
throw "[](/abchaos) MySQL Connection Failed";
|
console.log("MySQL Connection Failed");
|
||||||
|
return Rank.Guest;
|
||||||
}
|
}
|
||||||
var query = 'SELECT * FROM chan_{1}_ranks WHERE name="{2}"'
|
var query = 'SELECT * FROM chan_{1}_ranks WHERE name="{2}"'
|
||||||
.replace(/\{1\}/, this.name)
|
.replace(/\{1\}/, this.name)
|
||||||
|
@ -130,7 +133,8 @@ Channel.prototype.saveRank = function(user) {
|
||||||
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
||||||
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
||||||
if(!db.connectedSync()) {
|
if(!db.connectedSync()) {
|
||||||
throw "[](/abchaos) MySQL Connection Failed";
|
console.log("MySQL Connection Failed");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
var query = 'UPDATE chan_{1}_ranks SET rank={2} WHERE name={3}'
|
var query = 'UPDATE chan_{1}_ranks SET rank={2} WHERE name={3}'
|
||||||
.replace(/\{1\}/, this.name)
|
.replace(/\{1\}/, this.name)
|
||||||
|
@ -159,7 +163,8 @@ Channel.prototype.addToLibrary = function(media) {
|
||||||
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
db.connectSync(Config.MYSQL_SERVER, Config.MYSQL_USER,
|
||||||
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
Config.MYSQL_PASSWORD, Config.MYSQL_DB);
|
||||||
if(!db.connectedSync()) {
|
if(!db.connectedSync()) {
|
||||||
throw "[](/abchaos) MySQL Connection Failed";
|
console.log("MySQL Connection Failed");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
var query = 'INSERT INTO chan_{1}_library VALUES ("{2}", "{3}", {4}, "{5}", "{6}")'
|
var query = 'INSERT INTO chan_{1}_library VALUES ("{2}", "{3}", {4}, "{5}", "{6}")'
|
||||||
.replace(/\{1\}/, this.name)
|
.replace(/\{1\}/, this.name)
|
||||||
|
|
Loading…
Reference in a new issue