-
Notifications
You must be signed in to change notification settings - Fork 3
/
welcome-with-reset.ts
86 lines (71 loc) · 3.12 KB
/
welcome-with-reset.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* SudoSOS back-end API service.
* Copyright (C) 2024 Study association GEWIS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @license
*/
/**
* This is the module page of the welcome-with-reset.
*
* @module internal/mailer
*/
import MailMessage, { Language, MailLanguageMap } from '../mail-message';
import MailContentBuilder from './mail-content-builder';
import { ResetTokenInfo } from '../../service/authentication-service';
interface WelcomeWithResetOptions {
email: string,
resetTokenInfo: ResetTokenInfo,
url?: string;
}
const welcomeWithResetDutch = new MailContentBuilder<WelcomeWithResetOptions>({
getHTML: (context) => `
<p>Er is zojuist een account voor je aangemaakt in SudoSOS. Welkom!</p>
<p>Voordat je SudoSOS écht kunt gebruiken, dien je een wachtwoord te kiezen door te gaan naar ${context.url + '/passwordreset?token=' + context.resetTokenInfo.password + '&email=' + context.email}</p>
<p>Tot op de borrel!</p>`,
getSubject: 'Welkom bij SudoSOS!',
getTitle: 'Welkom!',
getText: (context) => `
Er is zojuist een account voor je aangemaakt in SudoSOS. Welkom!
Voordat je SudoSOS écht kunt gebruiken, dien je een wachtwoord te kiezen door te gaan naar ${context.url + '/passwordreset?token=' + context.resetTokenInfo.password + '&email=' + context.email}
Tot op de borrel!`,
});
const welcomeWithResetEnglish = new MailContentBuilder<WelcomeWithResetOptions>({
getHTML: (context) => `
<p>An account for SudoSOS has just been created for you. Welcome!</p>
<p>Before you can actually use SudoSOS, you have to set a password by going to ${context.url + '/passwordreset?token=' + context.resetTokenInfo.password + '&email=' + context.email}</p>
<p>See you on the borrel!</p>`,
getSubject: 'Welcome to SudoSOS!',
getTitle: 'Welcome!',
getText: (context) => `
An account for SudoSOS has just been created for you. Welcome!
Before you can actually use SudoSOS, you have to set a password by going to ${context.url + '/passwordreset?token=' + context.resetTokenInfo.password + '&email=' + context.email}
See you on the borrel!`,
});
const mailContents: MailLanguageMap<WelcomeWithResetOptions> = {
[Language.DUTCH]: welcomeWithResetDutch,
[Language.ENGLISH]: welcomeWithResetEnglish,
};
export default class WelcomeWithReset extends MailMessage<WelcomeWithResetOptions> {
public constructor(options: WelcomeWithResetOptions) {
const opt: WelcomeWithResetOptions = {
...options,
};
if (!options.url) {
opt.url = process.env.url;
}
super(opt, mailContents);
}
}