mirror of
https://github.com/MaciejkaG/statki.git
synced 2024-11-30 06:32:54 +01:00
Compare commits
3 Commits
f6f5af9758
...
99d26fffdc
Author | SHA1 | Date | |
---|---|---|---|
|
99d26fffdc | ||
|
44fb002ae3 | ||
|
d113ac615c |
5
index.js
5
index.js
@ -208,7 +208,10 @@ app.post('/api/login', (req, res) => {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auth.startVerification(req.body.email, getIP(req, req.get('User-Agent'))).then(async result => {
|
|
||||||
|
const locale = new Lang(req.acceptsLanguages());
|
||||||
|
|
||||||
|
auth.startVerification(req.body.email, getIP(req), req.get('user-agent'), locale.lang).then(async result => {
|
||||||
if (result.status === 1 || result.status === -1) {
|
if (result.status === 1 || result.status === -1) {
|
||||||
req.session.userId = result.uid;
|
req.session.userId = result.uid;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ export class MailAuth {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
startVerification(email, ip, agent) {
|
startVerification(email, ip, agent, langId) {
|
||||||
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) => {
|
||||||
@ -125,7 +125,7 @@ export class MailAuth {
|
|||||||
if (error) reject(error);
|
if (error) reject(error);
|
||||||
const row = response[0];
|
const row = response[0];
|
||||||
|
|
||||||
const html = fs.readFileSync(path.join(__dirname, 'mail/auth-code-firsttime.html'), 'utf8');
|
const html = fs.readFileSync(path.join(__dirname, `mail/auth-code-firsttime-${langId}.html`), 'utf8');
|
||||||
let authCode = genCode();
|
let authCode = genCode();
|
||||||
|
|
||||||
await this.redis.set(`codeAuth:${authCode}`, row.user_id);
|
await this.redis.set(`codeAuth:${authCode}`, row.user_id);
|
||||||
@ -160,7 +160,7 @@ export class MailAuth {
|
|||||||
|
|
||||||
const row = response[0];
|
const row = response[0];
|
||||||
|
|
||||||
const html = fs.readFileSync(path.join(__dirname, 'mail/auth-code.html'), 'utf8');
|
const html = fs.readFileSync(path.join(__dirname, `mail/auth-code-${langId}.html`), 'utf8');
|
||||||
let authCode = genCode();
|
let authCode = genCode();
|
||||||
|
|
||||||
await this.redis.set(`codeAuth:${authCode}`, row.user_id);
|
await this.redis.set(`codeAuth:${authCode}`, row.user_id);
|
||||||
@ -173,7 +173,7 @@ export class MailAuth {
|
|||||||
|
|
||||||
const lookup = geoip.lookup(ip);
|
const lookup = geoip.lookup(ip);
|
||||||
|
|
||||||
const lookupData = `User-Agent: ${agent}\nAdres IP: ${ip}\nKraj: ${lookup.country}\nRegion: ${lookup.region}\nMiasto: ${lookup.city}`;
|
const lookupData = `User-Agent: ${agent}\nIP address: ${ip}\nCountry: ${lookup.country}\nRegion: ${lookup.region}\nCity: ${lookup.city}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.mail.sendMail({
|
await this.mail.sendMail({
|
||||||
|
@ -45,7 +45,5 @@ export class Lang {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
utils/mail/auth-code-en.html
Normal file
34
utils/mail/auth-code-en.html
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,400;1,700&family=Poppins:ital,wght@0,600;1,600&family=Roboto+Mono:ital@0;1&display=swap"
|
||||||
|
rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body style="background: rgb(0, 0, 0);color: white;;font-family: 'Lato', sans-serif;padding: 30px;">
|
||||||
|
<div style="margin:30px;text-align: center;font-size:1.3em;margin: auto;width: 35%;min-width:25em;padding:20px;">
|
||||||
|
<h2 style="font-family: 'Poppins', sans-serif;">Hey, {{ NICKNAME }}!</h2>
|
||||||
|
<p>Someone tried to log in to Statki using your account, if it wasn't you, ignore this
|
||||||
|
message.<br>The authorisation code is below, remember to not share it with anyone.</p>
|
||||||
|
<div
|
||||||
|
style="border: solid white 1px; border-radius: 15px;font-family: 'Roboto Mono', monospace;padding:15px;font-size: 1.5em;">
|
||||||
|
{{ CODE }}
|
||||||
|
</div>
|
||||||
|
<p>Following code expires after 10 minutes</p>
|
||||||
|
<p>Below is some information about a logging in device*</p>
|
||||||
|
<pre style="text-align: left;">{{ LOOKUP }}</pre>
|
||||||
|
<p style="font-size: 12px;">* Geolocation data may not be accurate.</p>
|
||||||
|
</div>
|
||||||
|
<p style="color:white;margin-bottom: 20px;margin-top: 20px;text-align: center;"><a href="https://maciejka.xyz/"
|
||||||
|
style="text-decoration: none;color:white;">Copyright © 2024 MCJK</a> | <a
|
||||||
|
href="https://statki.maciejka.xyz/"
|
||||||
|
style="text-decoration: none;color: rgb(85, 111, 255);">statki.maciejka.xyz</a><br>This message has been
|
||||||
|
sent automatically, do not reply to it.<br>For support, message <a
|
||||||
|
href="mailto:biz@maciejka.xyz">biz@maciejka.xyz</a></p>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
34
utils/mail/auth-code-firsttime-en.html
Normal file
34
utils/mail/auth-code-firsttime-en.html
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,400;1,700&family=Poppins:ital,wght@0,600;1,600&family=Roboto+Mono:ital@0;1&display=swap"
|
||||||
|
rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body style="background: rgb(0, 0, 0);color: white;;font-family: 'Lato', sans-serif;padding: 30px;">
|
||||||
|
<div style="margin:30px;text-align: center;font-size:1.3em;margin: auto;width: 35%;min-width:25em;padding:20px;">
|
||||||
|
<h2 style="font-family: 'Poppins', sans-serif;">Cześć!</h2>
|
||||||
|
<p>Someone tried to create a Statki (battleships) account with this e-mail. If it wasn't you, ignore this
|
||||||
|
message.<br>The authorisation code is below, remember to not share it with anyone.</p>
|
||||||
|
<div
|
||||||
|
style="border: solid white 1px; border-radius: 15px;font-family: 'Roboto Mono', monospace;padding:15px;font-size: 1.5em;">
|
||||||
|
{{ CODE }}
|
||||||
|
</div>
|
||||||
|
<p>Following code expires after 10 minutes</p>
|
||||||
|
<p>Below is some information about a logging in device*</p>
|
||||||
|
<pre style="text-align: left;">{{ LOOKUP }}</pre>
|
||||||
|
<p style="font-size: 12px;">* Geolocation data may not be accurate.</p>
|
||||||
|
</div>
|
||||||
|
<p style="color:white;margin-bottom: 20px;margin-top: 20px;text-align: center;"><a href="https://maciejka.xyz/"
|
||||||
|
style="text-decoration: none;color:white;">Copyright © 2024 MCJK</a> | <a
|
||||||
|
href="https://statki.maciejka.xyz/"
|
||||||
|
style="text-decoration: none;color: rgb(85, 111, 255);">statki.maciejka.xyz</a><br>This message has been
|
||||||
|
sent automatically, do not reply to it.<br>For support, message <a
|
||||||
|
href="mailto:biz@maciejka.xyz">biz@maciejka.xyz</a></p>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -21,13 +21,14 @@
|
|||||||
<p>Powyższy kod wygasa po 10 minutach</p>
|
<p>Powyższy kod wygasa po 10 minutach</p>
|
||||||
<p>Poniżej znajdują się informacje o logującym się urządzeniu*</p>
|
<p>Poniżej znajdują się informacje o logującym się urządzeniu*</p>
|
||||||
<pre style="text-align: left;">{{ LOOKUP }}</pre>
|
<pre style="text-align: left;">{{ LOOKUP }}</pre>
|
||||||
<p style="font-size: 12px;">* Dane lokalizacyjne mogą mijać się z prawdą. Traktuj je z dystansem</p>
|
<p style="font-size: 12px;">* Dane lokalizacyjne mogą nie być dokładne.</p>
|
||||||
</div>
|
</div>
|
||||||
<p style="color:white;margin-bottom: 20px;margin-top: 20px;text-align: center;"><a href="https://maciejka.xyz/"
|
<p style="color:white;margin-bottom: 20px;margin-top: 20px;text-align: center;"><a href="https://maciejka.xyz/"
|
||||||
style="text-decoration: none;color:white;">Copyright © 2024 MCJK</a> | <a
|
style="text-decoration: none;color:white;">Copyright © 2024 MCJK</a> | <a
|
||||||
href="https://statki.maciejka.xyz/"
|
href="https://statki.maciejka.xyz/"
|
||||||
style="text-decoration: none;color: rgb(85, 111, 255);">statki.maciejka.xyz</a><br>Ta wiadomość została
|
style="text-decoration: none;color: rgb(85, 111, 255);">statki.maciejka.xyz</a><br>Ta wiadomość została
|
||||||
wysłana automatycznie, nie odpowiadaj na nią.</p>
|
wysłana automatycznie, nie odpowiadaj na nią.<br>Jeżeli szukasz wsparcia, napisz na <a
|
||||||
|
href="mailto:biz@maciejka.xyz">biz@maciejka.xyz</a></p>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -21,13 +21,14 @@
|
|||||||
<p>Powyższy kod wygasa po 10 minutach</p>
|
<p>Powyższy kod wygasa po 10 minutach</p>
|
||||||
<p>Poniżej znajdują się informacje o logującym się urządzeniu*</p>
|
<p>Poniżej znajdują się informacje o logującym się urządzeniu*</p>
|
||||||
<pre style="text-align: left;">{{ LOOKUP }}</pre>
|
<pre style="text-align: left;">{{ LOOKUP }}</pre>
|
||||||
<p style="font-size: 12px;">* Dane lokalizacyjne mogą mijać się z prawdą. Traktuj je z dystansem</p>
|
<p style="font-size: 12px;">* Dane lokalizacyjne mogą nie być dokładne.</p>
|
||||||
</div>
|
</div>
|
||||||
<p style="color:white;margin-bottom: 20px;margin-top: 20px;text-align: center;"><a href="https://maciejka.xyz/"
|
<p style="color:white;margin-bottom: 20px;margin-top: 20px;text-align: center;"><a href="https://maciejka.xyz/"
|
||||||
style="text-decoration: none;color:white;">Copyright © 2024 MCJK</a> | <a
|
style="text-decoration: none;color:white;">Copyright © 2024 MCJK</a> | <a
|
||||||
href="https://statki.maciejka.xyz/"
|
href="https://statki.maciejka.xyz/"
|
||||||
style="text-decoration: none;color: rgb(85, 111, 255);">statki.maciejka.xyz</a><br>Ta wiadomość została
|
style="text-decoration: none;color: rgb(85, 111, 255);">statki.maciejka.xyz</a><br>Ta wiadomość została
|
||||||
wysłana automatycznie, nie odpowiadaj na nią.</p>
|
wysłana automatycznie, nie odpowiadaj na nią.<br>Jeżeli szukasz wsparcia, napisz na <a
|
||||||
|
href="mailto:biz@maciejka.xyz">biz@maciejka.xyz</a></p>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user