Compare commits

...

10 Commits

Author SHA1 Message Date
6764bf80ea chore(release): 1.2.0
All checks were successful
ci/woodpecker/tag/release Pipeline was successful
2024-12-11 20:05:31 +01:00
b3a73b25e8 refactor(ci): Switch to new woodpecker 2024-12-11 20:05:07 +01:00
bda1f971d1 Merge pull request 'refactor: move to new mailer' (#209) from refactor/new-mailer into dev
Reviewed-on: #209
Reviewed-by: Nicolai Ort <info@nicolai-ort.com>
2024-12-11 19:04:11 +00:00
765ef84903 SELFSERVICE_URL 2024-12-11 18:43:11 +01:00
296ba8ddab FRONTEND_URL env 2024-12-11 18:40:21 +01:00
6eff243803 feat: middlename 2024-12-11 18:34:40 +01:00
0f4c8b2051 refactor: move to new mailer 2024-12-11 18:26:57 +01:00
d842c14240 chore: update readme 2024-12-11 17:55:04 +01:00
a54cb287a4 🚀Bumped version to v1.1.4 2024-11-20 19:00:19 +01:00
74d334f9b7 fix(dependencies): Switch back to previous class-validator version to produce a working build 2024-11-20 18:59:50 +01:00
9 changed files with 76 additions and 61 deletions

View File

@@ -8,3 +8,4 @@ DB_NAME=./test.sqlite
NODE_ENV=production NODE_ENV=production
POSTALCODE_COUNTRYCODE=DE POSTALCODE_COUNTRYCODE=DE
SEED_TEST_DATA=false SEED_TEST_DATA=false
SELFSERVICE_URL=bla

View File

@@ -7,14 +7,11 @@ steps:
- latest - latest
registry: registry.odit.services registry: registry.odit.services
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
cache_from: registry.odit.services/lfk/backend:latest cache_from: registry.odit.services/lfk/backend:dev
username: username:
from_secret: odit-registry-builder-username from_secret: odit-registry-builder-username
password: password:
from_secret: odit-registry-builder-password from_secret: odit-registry-builder-password
secrets:
- source: odit-npm-cache-url
target: NPM_REGISTRY_URL
when: when:
branch: main branch: main
- name: build dev - name: build dev
@@ -30,9 +27,6 @@ steps:
from_secret: odit-registry-builder-username from_secret: odit-registry-builder-username
password: password:
from_secret: odit-registry-builder-password from_secret: odit-registry-builder-password
secrets:
- source: odit-npm-cache-url
target: NPM_REGISTRY_URL
when: when:
branch: dev branch: dev
when: when:

View File

@@ -7,23 +7,11 @@ steps:
- "${CI_COMMIT_TAG}" - "${CI_COMMIT_TAG}"
registry: registry.odit.services registry: registry.odit.services
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
cache_from: registry.odit.services/lfk/backend:latest cache_from: registry.odit.services/lfk/backend:dev
username: username:
from_secret: odit-registry-builder-username from_secret: odit-registry-builder-username
password: password:
from_secret: odit-registry-builder-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: when:
event: tag event:
- tag

View File

@@ -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

View File

@@ -2,8 +2,21 @@
All notable changes to this project will be documented in this file. Dates are displayed in UTC. All notable changes to this project will be documented in this file. Dates are displayed in UTC.
#### [v1.1.4](https://git.odit.services/lfk/backend/compare/v1.1.3...v1.1.4)
- build: package lock [`50dd703`](https://git.odit.services/lfk/backend/commit/50dd703a1bd276a607cc10a087c7e90fd880847a)
- fix(deps): Bump sqlite3 [`cd3cd81`](https://git.odit.services/lfk/backend/commit/cd3cd81360777e8bc4d78e861354e58c8da79cc7)
- feat(ci)!: Switch to woodpecker [`3192365`](https://git.odit.services/lfk/backend/commit/3192365793fae59f2b89e3231db298654f0a28e9)
- fix(deps): Bumped argon2 to latest version for arm support [`cf48c00`](https://git.odit.services/lfk/backend/commit/cf48c00ddb2ac33263549876928db50ae152c12d)
- fix: updated README for pnpm, typos [`5082b1b`](https://git.odit.services/lfk/backend/commit/5082b1b8b1c0ae9e8ffa9c71c4d7923fd9223c87)
- ci: drop lfk-client-node [`075d484`](https://git.odit.services/lfk/backend/commit/075d484f1169bfc5c5b68cb9712116b0e270b471)
- fix(dependencies): Switch back to previous class-validator version to produce a working build [`74d334f`](https://git.odit.services/lfk/backend/commit/74d334f9b747a77115bd9b97729ef1120822e128)
#### [v1.1.3](https://git.odit.services/lfk/backend/compare/v1.1.2...v1.1.3) #### [v1.1.3](https://git.odit.services/lfk/backend/compare/v1.1.2...v1.1.3)
> 10 May 2023
- 🚀Bumped version to v1.1.3 [`057a8ee`](https://git.odit.services/lfk/backend/commit/057a8ee699d08c0e4a80cb50a8820f819569c9ac)
- feat(orgs): Also resolve child-teams' distances and add them to org total [`8d94186`](https://git.odit.services/lfk/backend/commit/8d9418635d3e381c0f55a2521a3334ba497c169a) - feat(orgs): Also resolve child-teams' distances and add them to org total [`8d94186`](https://git.odit.services/lfk/backend/commit/8d9418635d3e381c0f55a2521a3334ba497c169a)
- fix(orgs): Removed unused log [`f2832a2`](https://git.odit.services/lfk/backend/commit/f2832a2daecc7bc7bbee4d4fceeab8db194730cf) - fix(orgs): Removed unused log [`f2832a2`](https://git.odit.services/lfk/backend/commit/f2832a2daecc7bc7bbee4d4fceeab8db194730cf)

View File

@@ -35,13 +35,6 @@ pnpm test:watch
pnpm test:ci 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 ### Generate Docs
```bash ```bash
pnpm docs 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 | | 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_URL | String(Url) | N/A | The mailer's base url (no trailing slash) |
| MAILER_KEY | String | N/A | The mailer's api key. | | 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) | | 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) | | PRIVACY_URL | String(Url) | /privacy | The link to a privacy page for the system (Defaults to the frontend's privacy page) |

View File

@@ -1,6 +1,6 @@
{ {
"name": "@odit/lfk-backend", "name": "@odit/lfk-backend",
"version": "1.1.3", "version": "1.2.0",
"main": "src/app.ts", "main": "src/app.ts",
"repository": "https://git.odit.services/lfk/backend", "repository": "https://git.odit.services/lfk/backend",
"engines": { "engines": {
@@ -31,7 +31,7 @@
"body-parser": "1.19.0", "body-parser": "1.19.0",
"check-password-strength": "2.0.2", "check-password-strength": "2.0.2",
"class-transformer": "0.3.1", "class-transformer": "0.3.1",
"class-validator": "0.13.1", "class-validator": "0.13.0",
"consola": "2.15.0", "consola": "2.15.0",
"cookie": "0.4.1", "cookie": "0.4.1",
"cookie-parser": "1.4.5", "cookie-parser": "1.4.5",

View File

@@ -131,7 +131,7 @@ export class RunnerSelfServiceController {
const token = JwtCreator.createSelfService(runner); const token = JwtCreator.createSelfService(runner);
try { 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) { } catch (error) {
throw new MailSendingError(); throw new MailSendingError();
} }
@@ -157,7 +157,7 @@ export class RunnerSelfServiceController {
response.token = JwtCreator.createSelfService(runner); response.token = JwtCreator.createSelfService(runner);
try { 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) { } catch (error) {
throw new MailSendingError(); throw new MailSendingError();
} }
@@ -182,7 +182,7 @@ export class RunnerSelfServiceController {
response.token = JwtCreator.createSelfService(runner); response.token = JwtCreator.createSelfService(runner);
try { 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) { } catch (error) {
throw new MailSendingError(); throw new MailSendingError();
} }

View File

@@ -18,9 +18,19 @@ export class Mailer {
*/ */
public static async sendResetMail(to_address: string, token: string, locale: string = "en") { public static async sendResetMail(to_address: string, token: string, locale: string = "en") {
try { try {
await axios.post(`${Mailer.base}/reset?locale=${locale}&key=${Mailer.key}`, { await axios.request({
address: to_address, method: 'POST',
resetKey: token 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) { } catch (error) {
if (Mailer.testing) { return true; } if (Mailer.testing) { return true; }
@@ -32,12 +42,26 @@ export class Mailer {
* Function for sending a runner selfservice welcome mail. * 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 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. * @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 { try {
await axios.post(`${Mailer.base}/registration?locale=${locale}&key=${Mailer.key}`, { await axios.request({
address: to_address, method: 'POST',
selfserviceToken: token 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) { } catch (error) {
if (Mailer.testing) { return true; } if (Mailer.testing) { return true; }
@@ -49,12 +73,26 @@ export class Mailer {
* Function for sending a runner selfservice link forgotten mail. * 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 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. * @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 { try {
await axios.post(`${Mailer.base}/registration_forgot?locale=${locale}&key=${Mailer.key}`, { await axios.request({
address: to_address, method: 'POST',
selfserviceToken: token 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) { } catch (error) {
if (Mailer.testing) { return true; } if (Mailer.testing) { return true; }