diff --git a/.gitignore b/.gitignore index c2658d7..5b04c74 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.idea node_modules/ diff --git a/src/db/mysql.js b/src/db/mysql.js index f46fa23..cbdc068 100644 --- a/src/db/mysql.js +++ b/src/db/mysql.js @@ -101,8 +101,11 @@ export function createTable(name) { export function getUserByEmail(email) { return new Promise((resolve) => { this.db.instance.query(`SELECT * FROM ${CFG.SERVER_MYSQL_TABLE} WHERE email=? LIMIT 1`, [email], (e, rows, fields) => { - if (e) console.log(e); - else resolve(rows); + if (e) { + console.log(e); + } else { + resolve(rows[0]); + } }); }); } diff --git a/src/player.js b/src/player.js index aab0ba1..a62b3d2 100644 --- a/src/player.js +++ b/src/player.js @@ -77,7 +77,11 @@ class Player { updateByObject(obj) { for (let key in obj) { if (this.hasOwnProperty(key)) { - this[key] = obj[key]; + if (key == 'send_marketing_emails' || key == 'send_push_notifications') { + this[key] = !!obj[key]; + } else { + this[key] = obj[key]; + } } }; } @@ -283,6 +287,7 @@ export function loginPlayer() { return new Promise((resolve) => { this.getUserByEmail(player.email).then((doc) => { + console.log(doc); player.updateByObject(doc); buffer = GetPlayer(player).encode(); resolve(buffer);