Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
6764bf80ea | |||
b3a73b25e8 | |||
bda1f971d1 | |||
765ef84903 | |||
296ba8ddab | |||
6eff243803 | |||
0f4c8b2051 | |||
d842c14240 |
@ -7,4 +7,5 @@ DB_PASSWORD=bla
|
||||
DB_NAME=./test.sqlite
|
||||
NODE_ENV=production
|
||||
POSTALCODE_COUNTRYCODE=DE
|
||||
SEED_TEST_DATA=false
|
||||
SEED_TEST_DATA=false
|
||||
SELFSERVICE_URL=bla
|
@ -7,14 +7,11 @@ steps:
|
||||
- latest
|
||||
registry: registry.odit.services
|
||||
platforms: linux/amd64,linux/arm64
|
||||
cache_from: registry.odit.services/lfk/backend:latest
|
||||
cache_from: registry.odit.services/lfk/backend:dev
|
||||
username:
|
||||
from_secret: odit-registry-builder-username
|
||||
password:
|
||||
from_secret: odit-registry-builder-password
|
||||
secrets:
|
||||
- source: odit-npm-cache-url
|
||||
target: NPM_REGISTRY_URL
|
||||
when:
|
||||
branch: main
|
||||
- name: build dev
|
||||
@ -30,9 +27,6 @@ steps:
|
||||
from_secret: odit-registry-builder-username
|
||||
password:
|
||||
from_secret: odit-registry-builder-password
|
||||
secrets:
|
||||
- source: odit-npm-cache-url
|
||||
target: NPM_REGISTRY_URL
|
||||
when:
|
||||
branch: dev
|
||||
when:
|
||||
|
@ -7,23 +7,11 @@ steps:
|
||||
- "${CI_COMMIT_TAG}"
|
||||
registry: registry.odit.services
|
||||
platforms: linux/amd64,linux/arm64
|
||||
cache_from: registry.odit.services/lfk/backend:latest
|
||||
cache_from: registry.odit.services/lfk/backend:dev
|
||||
username:
|
||||
from_secret: odit-registry-builder-username
|
||||
password:
|
||||
from_secret: odit-registry-builder-password
|
||||
secrets:
|
||||
- source: odit-npm-cache-url
|
||||
target: NPM_REGISTRY_URL
|
||||
- name: trigger js lib build
|
||||
image: woodpeckerci/plugin-trigger
|
||||
settings:
|
||||
repositories:
|
||||
- lfk/lfk-client-js
|
||||
params:
|
||||
- "SOURCE_TAG=${CI_COMMIT_TAG}"
|
||||
token:
|
||||
from_secret: odit-ci-bot-apikey
|
||||
|
||||
when:
|
||||
event: tag
|
||||
event:
|
||||
- tag
|
||||
|
@ -1,13 +0,0 @@
|
||||
steps:
|
||||
- name: playwright tests
|
||||
image: registry.odit.services/hub/library/node:19.5.0-alpine3.16
|
||||
commands:
|
||||
- npm config set registry $NPM_REGISTRY_URL && npm i -g pnpm@8
|
||||
- pnpm i
|
||||
- pnpm test:ci
|
||||
secrets:
|
||||
- source: odit-npm-cache-url
|
||||
target: NPM_REGISTRY_URL
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
@ -35,13 +35,6 @@ pnpm test:watch
|
||||
pnpm test:ci
|
||||
```
|
||||
|
||||
### Use your own mail templates
|
||||
> You use your own mail templates by replacing the default ones we provided (either in-code or by mounting them into the /app/static/mail_templates folder).
|
||||
|
||||
The mail templates always come in a .html and a .txt variant to provide compatability with legacy mail clients.
|
||||
Currently the following templates exist:
|
||||
* pw-reset.(html/txt)
|
||||
|
||||
### Generate Docs
|
||||
```bash
|
||||
pnpm docs
|
||||
@ -66,6 +59,7 @@ pnpm docs
|
||||
| SEED_TEST_DATA | Boolean | False | If you want the app to seed some example data set this to true |
|
||||
| MAILER_URL | String(Url) | N/A | The mailer's base url (no trailing slash) |
|
||||
| MAILER_KEY | String | N/A | The mailer's api key. |
|
||||
| SELFSERVICE_URL | String(Url) | N/A | The link to selfservice (no trailing slash) |
|
||||
| IMPRINT_URL | String(Url) | /imprint | The link to a imprint page for the system (Defaults to the frontend's imprint) |
|
||||
| PRIVACY_URL | String(Url) | /privacy | The link to a privacy page for the system (Defaults to the frontend's privacy page) |
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@odit/lfk-backend",
|
||||
"version": "1.1.4",
|
||||
"version": "1.2.0",
|
||||
"main": "src/app.ts",
|
||||
"repository": "https://git.odit.services/lfk/backend",
|
||||
"engines": {
|
||||
@ -114,4 +114,4 @@
|
||||
"docs/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -131,7 +131,7 @@ export class RunnerSelfServiceController {
|
||||
const token = JwtCreator.createSelfService(runner);
|
||||
|
||||
try {
|
||||
await Mailer.sendSelfserviceForgottenMail(runner.email, token, locale)
|
||||
await Mailer.sendSelfserviceForgottenMail(runner.email, runner.id, runner.firstname, runner.middlename, runner.lastname, token, locale)
|
||||
} catch (error) {
|
||||
throw new MailSendingError();
|
||||
}
|
||||
@ -157,7 +157,7 @@ export class RunnerSelfServiceController {
|
||||
response.token = JwtCreator.createSelfService(runner);
|
||||
|
||||
try {
|
||||
await Mailer.sendSelfserviceWelcomeMail(runner.email, response.token, locale)
|
||||
await Mailer.sendSelfserviceWelcomeMail(runner.email, runner.id, runner.firstname, runner.middlename, runner.lastname, response.token, locale)
|
||||
} catch (error) {
|
||||
throw new MailSendingError();
|
||||
}
|
||||
@ -182,7 +182,7 @@ export class RunnerSelfServiceController {
|
||||
response.token = JwtCreator.createSelfService(runner);
|
||||
|
||||
try {
|
||||
await Mailer.sendSelfserviceWelcomeMail(runner.email, response.token, locale)
|
||||
await Mailer.sendSelfserviceWelcomeMail(runner.email, runner.id, runner.firstname, runner.middlename, runner.lastname, response.token, locale)
|
||||
} catch (error) {
|
||||
throw new MailSendingError();
|
||||
}
|
||||
|
@ -18,9 +18,19 @@ export class Mailer {
|
||||
*/
|
||||
public static async sendResetMail(to_address: string, token: string, locale: string = "en") {
|
||||
try {
|
||||
await axios.post(`${Mailer.base}/reset?locale=${locale}&key=${Mailer.key}`, {
|
||||
address: to_address,
|
||||
resetKey: token
|
||||
await axios.request({
|
||||
method: 'POST',
|
||||
url: `${Mailer.base}/api/v1/email`,
|
||||
headers: {
|
||||
authorization: `Bearer ${Mailer.key}`,
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
data: {
|
||||
to: to_address,
|
||||
templateName: 'password-reset',
|
||||
language: locale,
|
||||
data: { token: token }
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
if (Mailer.testing) { return true; }
|
||||
@ -32,12 +42,26 @@ export class Mailer {
|
||||
* Function for sending a runner selfservice welcome mail.
|
||||
* @param to_address The address the mail will be sent to. Should always get pulled from a runner object.
|
||||
* @param token The requested selfservice token - will be combined with the app_url to generate a selfservice profile link.
|
||||
*/
|
||||
public static async sendSelfserviceWelcomeMail(to_address: string, token: string, locale: string = "en") {
|
||||
*/
|
||||
public static async sendSelfserviceWelcomeMail(to_address: string, runner_id: number, firstname: string, middlename: string, lastname: string, token: string, locale: string = "en") {
|
||||
try {
|
||||
await axios.post(`${Mailer.base}/registration?locale=${locale}&key=${Mailer.key}`, {
|
||||
address: to_address,
|
||||
selfserviceToken: token
|
||||
await axios.request({
|
||||
method: 'POST',
|
||||
url: `${Mailer.base}/api/v1/email`,
|
||||
headers: {
|
||||
authorization: `Bearer ${Mailer.key}`,
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
data: {
|
||||
to: to_address,
|
||||
templateName: 'welcome',
|
||||
language: locale,
|
||||
data: {
|
||||
name: `${firstname} ${middlename} ${lastname}`,
|
||||
barcode_content: `${runner_id}`,
|
||||
link: `${process.env.SELFSERVICE_URL}/profile/${token}`
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
if (Mailer.testing) { return true; }
|
||||
@ -49,12 +73,26 @@ export class Mailer {
|
||||
* Function for sending a runner selfservice link forgotten mail.
|
||||
* @param to_address The address the mail will be sent to. Should always get pulled from a runner object.
|
||||
* @param token The requested selfservice token - will be combined with the app_url to generate a selfservice profile link.
|
||||
*/
|
||||
public static async sendSelfserviceForgottenMail(to_address: string, token: string, locale: string = "en") {
|
||||
*/
|
||||
public static async sendSelfserviceForgottenMail(to_address: string, runner_id: number, firstname: string, middlename: string, lastname: string, token: string, locale: string = "en") {
|
||||
try {
|
||||
await axios.post(`${Mailer.base}/registration_forgot?locale=${locale}&key=${Mailer.key}`, {
|
||||
address: to_address,
|
||||
selfserviceToken: token
|
||||
await axios.request({
|
||||
method: 'POST',
|
||||
url: `${Mailer.base}/api/v1/email`,
|
||||
headers: {
|
||||
authorization: `Bearer ${Mailer.key}`,
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
data: {
|
||||
to: to_address,
|
||||
templateName: 'welcome',
|
||||
language: locale,
|
||||
data: {
|
||||
name: `${firstname} ${middlename} ${lastname}`,
|
||||
barcode_content: `${runner_id}`,
|
||||
link: `${process.env.SELFSERVICE_URL}/profile/${token}`
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
if (Mailer.testing) { return true; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user