From ef3d1e56b14e81957c605020530fe0869785a08b Mon Sep 17 00:00:00 2001 From: sw-wayner Date: Tue, 9 Jan 2024 14:01:57 -0400 Subject: [PATCH] fix(users): await `user activated` update --- lib/server/routes/users.js | 30 ++++++++++++++++----------- tests/lib/e2e/users/users.e2e-spec.ts | 2 +- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/server/routes/users.js b/lib/server/routes/users.js index 470becc6..48c5070e 100644 --- a/lib/server/routes/users.js +++ b/lib/server/routes/users.js @@ -181,23 +181,29 @@ UsersRouter.prototype.createUser = function (req, res, next) { trackUserActivated(user.uuid, req.body.email); - user.save(); + user.save((err) => { - /* - analytics.identify(req.headers.dnt, { - userId: user.uuid, - traits: { - activated: false + if (err) { + return next(err); } - }); + /* + analytics.identify(req.headers.dnt, { + userId: user.uuid, + traits: { + activated: false + } + }); - analytics.track(req.headers.dnt, { - userId: user.uuid, - event: 'User Created' + analytics.track(req.headers.dnt, { + userId: user.uuid, + event: 'User Created' + }); + */ + + self._dispatchAndCreatePubKey(user, req, res, next); }); - */ - self._dispatchAndCreatePubKey(user, req, res, next); + }); } }; diff --git a/tests/lib/e2e/users/users.e2e-spec.ts b/tests/lib/e2e/users/users.e2e-spec.ts index 785d301d..59286455 100644 --- a/tests/lib/e2e/users/users.e2e-spec.ts +++ b/tests/lib/e2e/users/users.e2e-spec.ts @@ -42,7 +42,7 @@ describe('Bridge E2E Tests', () => { const users = await engine.storage.models.User.find({ _id: response.body.id }) expect(users).toHaveLength(1) - // expect(users[0].toObject().activated).toBe(true) + expect(users[0].toObject().activated).toBe(true) // expect(dispatchSendGridMock).toHaveBeenCalled()