Wrote basic banning system
This commit is contained in:
@@ -23,6 +23,7 @@ Minor
|
|||||||
Patch
|
Patch
|
||||||
---
|
---
|
||||||
|
|
||||||
|
* Open the game ladder to the page the player is on.
|
||||||
* Game Balance - move balance variables to a config file.
|
* Game Balance - move balance variables to a config file.
|
||||||
* Images to social media instead of links.
|
* Images to social media instead of links.
|
||||||
* Occasional flickering when rendering Profile page.
|
* Occasional flickering when rendering Profile page.
|
||||||
|
|||||||
@@ -35,6 +35,18 @@ const signupRequest = (connection) => (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check to see if the email has been banned
|
||||||
|
let query = 'SELECT COUNT(*) as total FROM bannedEmails WHERE email = ?;';
|
||||||
|
connection.query(query, [fields.email], (err, results) => {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
|
//if the email has been banned
|
||||||
|
if (results[0].total > 0) {
|
||||||
|
res.status(400).write(log('This email account has been banned!', 'signup', fields.email, fields.username));
|
||||||
|
res.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//check if email, username already exists
|
//check if email, username already exists
|
||||||
let query = 'SELECT (SELECT COUNT(*) FROM accounts WHERE email = ?) AS email, (SELECT COUNT(*) FROM accounts WHERE username = ?) AS username;';
|
let query = 'SELECT (SELECT COUNT(*) FROM accounts WHERE email = ?) AS email, (SELECT COUNT(*) FROM accounts WHERE username = ?) AS username;';
|
||||||
connection.query(query, [fields.email, fields.username], (err, results) => {
|
connection.query(query, [fields.email, fields.username], (err, results) => {
|
||||||
@@ -105,6 +117,7 @@ const signupRequest = (connection) => (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const verifyRequest = (connection) => (req, res) => {
|
const verifyRequest = (connection) => (req, res) => {
|
||||||
@@ -167,6 +180,18 @@ const loginRequest = (connection) => (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check to see if the email has been banned
|
||||||
|
let query = 'SELECT COUNT(*) as total FROM bannedEmails WHERE email = ?;';
|
||||||
|
connection.query(query, [fields.email], (err, results) => {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
|
//if the email has been banned
|
||||||
|
if (results[0].total > 0) {
|
||||||
|
res.status(400).write(log('This email account has been banned!', 'login', fields.email));
|
||||||
|
res.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//find this email's information
|
//find this email's information
|
||||||
let query = 'SELECT id, username, salt, hash FROM accounts WHERE email = ?;';
|
let query = 'SELECT id, username, salt, hash FROM accounts WHERE email = ?;';
|
||||||
connection.query(query, [fields.email], (err, results) => {
|
connection.query(query, [fields.email], (err, results) => {
|
||||||
@@ -212,6 +237,7 @@ const loginRequest = (connection) => (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const logoutRequest = (connection) => (req, res) => {
|
const logoutRequest = (connection) => (req, res) => {
|
||||||
|
|||||||
@@ -209,3 +209,12 @@ CREATE TABLE IF NOT EXISTS badges (
|
|||||||
#
|
#
|
||||||
# CONSTRAINT FOREIGN KEY fk_accountId(accountId) REFERENCES accounts(id) ON UPDATE CASCADE ON DELETE CASCADE
|
# CONSTRAINT FOREIGN KEY fk_accountId(accountId) REFERENCES accounts(id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
#);
|
#);
|
||||||
|
|
||||||
|
#banning system
|
||||||
|
CREATE TABLE IF NOT EXISTS bannedEmails (
|
||||||
|
id INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE,
|
||||||
|
td TIMESTAMP DEFAULT CURRENT_TIMESTAMP(),
|
||||||
|
|
||||||
|
email VARCHAR(320) UNIQUE,
|
||||||
|
reason VARCHAR(1000)
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user