Now generateing api key via eng_gen script
This commit is contained in:
parent
01f5001355
commit
17f5876d73
|
@ -8,14 +8,21 @@ nodemailer.createTestAccount((err, account) => {
|
||||||
console.error('Failed to create a testing account. ' + err.message);
|
console.error('Failed to create a testing account. ' + err.message);
|
||||||
return process.exit(1);
|
return process.exit(1);
|
||||||
}
|
}
|
||||||
|
let apikey = '';
|
||||||
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
const charactersLength = characters.length;
|
||||||
|
for (var i = 0; i < 64; i++) {
|
||||||
|
apikey += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||||
|
}
|
||||||
const env = `
|
const env = `
|
||||||
NODE_ENV=dev
|
NODE_ENV=dev
|
||||||
MAIL_SERVER=${account.smtp.host}
|
MAIL_SERVER=${account.smtp.host}
|
||||||
MAIL_PORT=${account.smtp.port}
|
MAIL_PORT=${account.smtp.port}
|
||||||
MAIL_USER=${account.user}
|
MAIL_USER=${account.user}
|
||||||
MAIL_PASSWORD=${account.pass}
|
MAIL_PASSWORD=${account.pass}
|
||||||
MAIL_FROM=${account.user}`
|
MAIL_FROM=${account.user}
|
||||||
|
API_KEY=${apikey}
|
||||||
|
`
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync("./.env", env, { encoding: "utf-8" });
|
fs.writeFileSync("./.env", env, { encoding: "utf-8" });
|
||||||
|
|
|
@ -26,4 +26,20 @@ export class MailController {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('/test')
|
||||||
|
@OpenAPI({ description: "Sends test mails" })
|
||||||
|
async sendTest(@QueryParam("locale") locale: string) {
|
||||||
|
if (!this.initialized) {
|
||||||
|
await this.mailer.init();
|
||||||
|
this.initialized = true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.mailer.sendTestMail(locale)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
"imprint": "Imprint",
|
"imprint": "Imprint",
|
||||||
"lfk-mail-test": "LfK! - Mail test",
|
"lfk-mail-test": "LfK! - Mail test",
|
||||||
"privacy": "Privacy",
|
"privacy": "Privacy",
|
||||||
"subject_reset": "{{copyright_owner}} password reset",
|
"subject_reset": "{copyright_owner} password reset",
|
||||||
"test-mail": "Test mail",
|
"test-mail": "Test mail",
|
||||||
"this-is-a-test-mail-triggered-by-an-admin-in-the-lfk-backend": "This is a test mail triggered by an admin in the LfK! backend.",
|
"this-is-a-test-mail-triggered-by-an-admin-in-the-lfk-backend": "This is a test mail triggered by an admin in the LfK! backend.",
|
||||||
"this-mail-was-sent-to-recipient_mail-because-someone-request-a-mail-test-for-this-mail-address": "This mail was sent to {{recipient_mail}} because someone request a mail test for this mail address."
|
"this-mail-was-sent-to-recipient_mail-because-someone-request-a-mail-test-for-this-mail-address": "This mail was sent to {{to_address}} because someone request a mail test for this mail address.",
|
||||||
|
"subject_test": "subject_test"
|
||||||
}
|
}
|
Loading…
Reference in New Issue