diff --git a/package.json b/package.json index ce778a0..3d9213b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "POGOServer", - "version": "0.2.9", + "version": "0.3.0", "description": "", "repository": { "type": "git", diff --git a/src/db/mongo.js b/src/db/mongo.js index e2c6814..17d34cf 100644 --- a/src/db/mongo.js +++ b/src/db/mongo.js @@ -73,7 +73,8 @@ export function getUserByEmail(email) { return new Promise((resolve) => { let collection = this.getUserCollection(); collection.find({email: email}).toArray((err, docs) => { - resolve(docs); + if (docs && docs.length) resolve(docs[0]); + else resolve(void 0); }); }); } diff --git a/src/db/mysql.js b/src/db/mysql.js index 1d27f21..2e19d04 100644 --- a/src/db/mysql.js +++ b/src/db/mysql.js @@ -101,11 +101,9 @@ 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[0]); - } + if (e) console.log(e); + if (rows && rows.length) resolve(rows[0]); + else resolve(void 0); }); }); } diff --git a/src/player.js b/src/player.js index 6ef4751..58e05cf 100644 --- a/src/player.js +++ b/src/player.js @@ -304,13 +304,13 @@ export function forwardPlayer() { if (player.email.length) { this.print(`${player.email.replace("@gmail.com", "")} authenticated!`, 36); } - if (doc === void 0 || doc && !doc.length) { - this.registerPlayer().then((res) => { + if (doc) { + this.loginPlayer().then((res) => { resolve(res); }); } else { - this.loginPlayer().then((res) => { + this.registerPlayer().then((res) => { resolve(res); }); } diff --git a/src/setup.js b/src/setup.js index ca2b912..e552bf3 100644 --- a/src/setup.js +++ b/src/setup.js @@ -33,4 +33,4 @@ export function setup() { }); }); -} +} \ No newline at end of file