Database bug fix

- Multiple account bug fix
This commit is contained in:
Felix 2016-08-17 21:44:18 +02:00
parent c6e52d8207
commit 7885c90b3c
5 changed files with 10 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{
"name": "POGOServer",
"version": "0.2.9",
"version": "0.3.0",
"description": "",
"repository": {
"type": "git",

View File

@ -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);
});
});
}

View File

@ -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);
});
});
}

View File

@ -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);
});
}

View File

@ -33,4 +33,4 @@ export function setup() {
});
});
}
}