Wrote basic banning system
This commit is contained in:
@@ -23,6 +23,7 @@ Minor
|
||||
Patch
|
||||
---
|
||||
|
||||
* Open the game ladder to the page the player is on.
|
||||
* Game Balance - move balance variables to a config file.
|
||||
* Images to social media instead of links.
|
||||
* Occasional flickering when rendering Profile page.
|
||||
|
||||
+28
-2
@@ -35,6 +35,18 @@ const signupRequest = (connection) => (req, res) => {
|
||||
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
|
||||
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) => {
|
||||
@@ -70,7 +82,7 @@ const signupRequest = (connection) => (req, res) => {
|
||||
//build the verification email
|
||||
let addr = `http://${process.env.WEB_ADDRESS}/verifyrequest?email=${fields.email}&verify=${rand}`;
|
||||
let msg = 'Hello! Please visit the following address to verify your account: ';
|
||||
// let msgHtml = `<html><body><p>${msg}<a href='${addr}'>${addr}</a></p></body></html>`;
|
||||
// let msgHtml = `<html><body><p>${msg}<a href='${addr}'>${addr}</a></p></body></html>`;
|
||||
|
||||
//BUGFIX: is gmail being cruel?
|
||||
let sentinel = false;
|
||||
@@ -81,7 +93,7 @@ const signupRequest = (connection) => (req, res) => {
|
||||
to: fields.email,
|
||||
subject: 'Email Verification',
|
||||
text: msg + addr,
|
||||
// html: msgHtml
|
||||
// html: msgHtml
|
||||
}, (err, reply) => {
|
||||
if (err) { //final check
|
||||
let msg = log('Something went wrong (did you use a valid email?)', err);
|
||||
@@ -105,6 +117,7 @@ const signupRequest = (connection) => (req, res) => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const verifyRequest = (connection) => (req, res) => {
|
||||
@@ -167,6 +180,18 @@ const loginRequest = (connection) => (req, res) => {
|
||||
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
|
||||
let query = 'SELECT id, username, salt, hash FROM accounts WHERE email = ?;';
|
||||
connection.query(query, [fields.email], (err, results) => {
|
||||
@@ -212,6 +237,7 @@ const loginRequest = (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
|
||||
#);
|
||||
|
||||
#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