Skip to content

Commit a8c36d1

Browse files
authored
Merge pull request #129 from accounts-js/feature/configurable-email-templates
Add configurable email templates
2 parents a8e0626 + bd73e43 commit a8c36d1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/server/src/accounts-server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ export class AccountsServer {
9494
this.email = this._options.sendMail
9595
? { sendMail: this._options.sendMail }
9696
: new Email(this._options.email);
97-
this.emailTemplates = emailTemplates;
97+
98+
this.emailTemplates = this._options.emailTemplates;
9899

99100
if (!this.hooks) {
100101
this.hooks = new EventEmitter();
@@ -300,6 +301,8 @@ export class AccountsServer {
300301
proposedUserObject
301302
);
302303

304+
// TODO: Send enrollment email if flag is on
305+
303306
return userId;
304307
} catch (error) {
305308
this.hooks.emit(ServerHooks.CreateUserError, error);

packages/server/src/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
config as sharedConfig,
99
PasswordSignupFields,
1010
} from '@accounts/common';
11-
import { EmailTemplateType } from './email-templates';
11+
import emailTemplates, { EmailTemplateType, EmailTemplatesType } from './email-templates';
1212

1313
export type PasswordAuthenticator = (
1414
user: PasswordLoginUserType,
@@ -55,6 +55,7 @@ export type AccountsServerConfiguration = AccountsCommonConfiguration & {
5555
tokenConfigs?: TokenConfig;
5656
passwordAuthenticator?: PasswordAuthenticator;
5757
resumeSessionValidator?: ResumeSessionValidator;
58+
emailTemplates?: EmailTemplatesType;
5859
prepareMail?: PrepareMailFunction;
5960
sendMail?: SendMailFunction;
6061
// https://github.com/eleith/emailjs#emailserverconnectoptions
@@ -83,4 +84,5 @@ export default {
8384
userObjectSanitizer: (user: UserObjectType) => user,
8485
allowedLoginFields: ['id', 'email', 'username'],
8586
emailTokensExpiry: 1000 * 3600, // 1 hour in milis
87+
emailTemplates
8688
};

0 commit comments

Comments
 (0)