diff --git a/express/src/controllers/register.ts b/express/src/controllers/register.ts index 350134a29..c8c42890c 100644 --- a/express/src/controllers/register.ts +++ b/express/src/controllers/register.ts @@ -19,6 +19,7 @@ export const processGetEmailForm: RequestHandler = async (req, res) => { console.info("In ProcessGetEmailForm"); req.session.emailAddress = emailAddress; + req.session.save(); try { await s4.createUser(emailAddress); diff --git a/express/tests/controllers/register.test.ts b/express/tests/controllers/register.test.ts index a86bc3582..62d2af687 100644 --- a/express/tests/controllers/register.test.ts +++ b/express/tests/controllers/register.test.ts @@ -82,6 +82,7 @@ describe("processGetEmailForm controller tests", () => { await processGetEmailForm(mockReq, mockRes, mockNext); expect(s4CreateUserSpy).toHaveBeenCalledWith(TEST_EMAIL); + expect(mockReq.session.save).toHaveBeenCalled(); expect(mockRes.redirect).toHaveBeenCalledWith("/register/enter-email-code"); }); @@ -106,6 +107,7 @@ describe("processGetEmailForm controller tests", () => { await processGetEmailForm(mockReq, mockRes, mockNext); expect(s4CreateUserSpy).toHaveBeenCalledWith(TEST_EMAIL); expect(s4SignUpStatusSpy).toHaveBeenCalledWith(TEST_EMAIL); + expect(mockReq.session.save).toHaveBeenCalled(); expect(console.info).toHaveBeenCalledWith("Processing No HasEMail"); expect(mockRes.redirect).toHaveBeenCalledWith("resume-before-password"); }); @@ -134,6 +136,7 @@ describe("processGetEmailForm controller tests", () => { expect(s4CreateUserSpy).toHaveBeenCalledWith(TEST_EMAIL); expect(s4SignUpStatusSpy).toHaveBeenCalledWith(TEST_EMAIL); expect(console.info).toHaveBeenCalledWith("Processing No HasPassword"); + expect(mockReq.session.save).toHaveBeenCalled(); expect(mockRes.redirect).toHaveBeenCalledWith("resume-before-password"); }); @@ -162,6 +165,7 @@ describe("processGetEmailForm controller tests", () => { expect(s4CreateUserSpy).toHaveBeenCalledWith(TEST_EMAIL); expect(s4SignUpStatusSpy).toHaveBeenCalledWith(TEST_EMAIL); expect(console.info).toHaveBeenCalledWith("Processing No HasPhoneNumber"); + expect(mockReq.session.save).toHaveBeenCalled(); expect(mockRes.redirect).toHaveBeenCalledWith("resume-after-password"); }); @@ -190,6 +194,7 @@ describe("processGetEmailForm controller tests", () => { await processGetEmailForm(mockReq, mockRes, mockNext); expect(s4CreateUserSpy).toHaveBeenCalledWith(TEST_EMAIL); expect(s4SignUpStatusSpy).toHaveBeenCalledWith(TEST_EMAIL); + expect(mockReq.session.save).toHaveBeenCalled(); expect(console.info).toHaveBeenCalledWith("Processing No HasTextCode"); expect(mockRes.redirect).toHaveBeenCalledWith("resume-after-password"); }); @@ -207,6 +212,7 @@ describe("processGetEmailForm controller tests", () => { await expect(processGetEmailForm(mockReq, mockRes, mockNext)).rejects.toThrow(); expect(s4CreateUserSpy).toHaveBeenCalledWith(TEST_EMAIL); + expect(mockReq.session.save).toHaveBeenCalled(); expect(s4SignUpStatusSpy).not.toHaveBeenCalled(); }); });