Skip to content

Commit ba83969

Browse files
committed
bug(auth): Fix fxa mailer resolution bug
Becuase: - The InactiveAccountsManager couldn't resolve the an instance of fxaMailer This Commit: - Resolves the resolution issue by hoisting the DI registration.
1 parent 44b072d commit ba83969

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

packages/fxa-auth-server/bin/key_server.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,23 @@ async function run(config) {
326326
const senders = await require('../lib/senders')(log, config, bounces, statsd);
327327
const glean = gleanMetrics(config);
328328

329+
// Fxa Mailer Setup. Note, this should be done before anything that might
330+
// issue Container.get(FxaMailer) in it's constructor! We've been bit by this
331+
// service locator pattern before, so tread carefully.
332+
const emailSender = new EmailSender(config.smtp, bounces, statsd, log);
333+
const linkBuilderConfig = {
334+
baseUri: config.contentServer.url,
335+
...config.smtp,
336+
};
337+
const linkBuilder = new EmailLinkBuilder(linkBuilderConfig);
338+
const fxaMailer = new FxaMailer(
339+
emailSender,
340+
linkBuilder,
341+
config.smtp,
342+
new NodeRendererBindings()
343+
);
344+
Container.set(FxaMailer, fxaMailer);
345+
329346
// The AccountDeleteManager is dependent on some of the object set into
330347
// Container above.
331348
const accountTasks = DeleteAccountTasksFactory(config, statsd);
@@ -378,20 +395,6 @@ async function run(config) {
378395
const zendeskClient = require('../lib/zendesk-client').createZendeskClient(
379396
config
380397
);
381-
// mailer lib setup
382-
const emailSender = new EmailSender(config.smtp, bounces, statsd, log);
383-
const linkBuilderConfig = {
384-
baseUri: config.contentServer.url,
385-
...config.smtp,
386-
};
387-
const linkBuilder = new EmailLinkBuilder(linkBuilderConfig);
388-
const fxaMailer = new FxaMailer(
389-
emailSender,
390-
linkBuilder,
391-
config.smtp,
392-
new NodeRendererBindings()
393-
);
394-
Container.set(FxaMailer, fxaMailer);
395398

396399
const oauthClientInfo = require('../lib/senders/oauth_client_info');
397400
const { OAuthClientInfoServiceName } = oauthClientInfo;

0 commit comments

Comments
 (0)