mirror of
https://github.com/MaciejkaG/statki.git
synced 2024-11-30 02:32: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);
|
||||
const row = response[0];
|
||||
|
||||
conn.end();
|
||||
resolve({ status: 1, uid: row.user_id });
|
||||
});
|
||||
|
||||
@ -83,10 +84,9 @@ export class MailAuth {
|
||||
|
||||
const row = response[0];
|
||||
|
||||
conn.end();
|
||||
resolve({ status: 1, uid: row.user_id });
|
||||
});
|
||||
|
||||
conn.end();
|
||||
});
|
||||
}
|
||||
|
||||
@ -101,20 +101,21 @@ export class MailAuth {
|
||||
} else {
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
|
||||
conn.end();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
startVerification(email, ip, agent) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const conn = mysql.createConnection(this.mysqlOptions);
|
||||
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) {
|
||||
let timer = await this.redis.get(`loginTimer:${response[0].user_id}`);
|
||||
if (timer && timer > 0) {
|
||||
conn.end();
|
||||
resolve({ status: -1, uid: response[0].user_id, });
|
||||
return;
|
||||
}
|
||||
@ -155,6 +156,7 @@ export class MailAuth {
|
||||
reject(e);
|
||||
}
|
||||
|
||||
conn.end();
|
||||
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 });
|
||||
});
|
||||
|
||||
conn.end();
|
||||
});
|
||||
}
|
||||
|
||||
@ -206,10 +207,10 @@ export class MailAuth {
|
||||
if (error) reject(error);
|
||||
else resolve();
|
||||
});
|
||||
});
|
||||
|
||||
conn.end();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getProfile(userId) {
|
||||
@ -227,10 +228,10 @@ export class MailAuth {
|
||||
|
||||
resolve({ profile, stats, matchHistory });
|
||||
}
|
||||
});
|
||||
|
||||
conn.end();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
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) => {
|
||||
if (error) reject(error);
|
||||
resolve();
|
||||
});
|
||||
|
||||
conn.end();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getNickname(uid) {
|
||||
|
Loading…
Reference in New Issue
Block a user