mirror of
https://github.com/MaciejkaG/statki.git
synced 2024-11-30 04:42:55 +01:00
Major bug fixes
This commit is contained in:
parent
2e8f8952f3
commit
7e3db33ae8
@ -75,6 +75,7 @@ export class MailAuth {
|
|||||||
if (error) reject(error);
|
if (error) reject(error);
|
||||||
const row = response[0];
|
const row = response[0];
|
||||||
|
|
||||||
|
conn.end();
|
||||||
resolve({ status: 1, uid: row.user_id });
|
resolve({ status: 1, uid: row.user_id });
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -83,10 +84,9 @@ export class MailAuth {
|
|||||||
|
|
||||||
const row = response[0];
|
const row = response[0];
|
||||||
|
|
||||||
|
conn.end();
|
||||||
resolve({ status: 1, uid: row.user_id });
|
resolve({ status: 1, uid: row.user_id });
|
||||||
});
|
});
|
||||||
|
|
||||||
conn.end();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,20 +101,21 @@ export class MailAuth {
|
|||||||
} else {
|
} else {
|
||||||
resolve(null);
|
resolve(null);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
startVerification(email, ip, agent) {
|
startVerification(email, ip, agent) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const conn = mysql.createConnection(this.mysqlOptions);
|
const conn = mysql.createConnection(this.mysqlOptions);
|
||||||
conn.query(`SELECT user_id, nickname FROM accounts WHERE email = ${conn.escape(email)}`, async (error, response) => {
|
conn.query(`SELECT user_id, nickname FROM accounts WHERE email = ${conn.escape(email)}`, async (error, response) => {
|
||||||
if (error) { reject(error); return; }
|
if (error) { reject(error); conn.end(); return; }
|
||||||
if (response.length !== 0) {
|
if (response.length !== 0) {
|
||||||
let timer = await this.redis.get(`loginTimer:${response[0].user_id}`);
|
let timer = await this.redis.get(`loginTimer:${response[0].user_id}`);
|
||||||
if (timer && timer > 0) {
|
if (timer && timer > 0) {
|
||||||
|
conn.end();
|
||||||
resolve({ status: -1, uid: response[0].user_id, });
|
resolve({ status: -1, uid: response[0].user_id, });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -155,6 +156,7 @@ export class MailAuth {
|
|||||||
reject(e);
|
reject(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conn.end();
|
||||||
resolve({ status: 1, uid: row.user_id, code: authCode });
|
resolve({ status: 1, uid: row.user_id, code: authCode });
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -190,10 +192,9 @@ export class MailAuth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
conn.end();
|
||||||
resolve({ status: 1, uid: row.user_id });
|
resolve({ status: 1, uid: row.user_id });
|
||||||
});
|
});
|
||||||
|
|
||||||
conn.end();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,10 +207,10 @@ export class MailAuth {
|
|||||||
if (error) reject(error);
|
if (error) reject(error);
|
||||||
else resolve();
|
else resolve();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getProfile(userId) {
|
getProfile(userId) {
|
||||||
@ -227,10 +228,10 @@ export class MailAuth {
|
|||||||
|
|
||||||
resolve({ profile, stats, matchHistory });
|
resolve({ profile, stats, matchHistory });
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async finishVerification(uid, authCode) {
|
async finishVerification(uid, authCode) {
|
||||||
@ -251,10 +252,10 @@ export class MailAuth {
|
|||||||
conn.query(`UPDATE accounts SET nickname = ${conn.escape(nickname)} WHERE user_id = ${conn.escape(uid)}`, (error) => {
|
conn.query(`UPDATE accounts SET nickname = ${conn.escape(nickname)} WHERE user_id = ${conn.escape(uid)}`, (error) => {
|
||||||
if (error) reject(error);
|
if (error) reject(error);
|
||||||
resolve();
|
resolve();
|
||||||
});
|
|
||||||
|
|
||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getNickname(uid) {
|
getNickname(uid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user