diff --git a/packages/auth/src/features/authenticate/handler.test.ts b/packages/auth/src/features/authenticate/handler.test.ts index 36489e99369..fc665e6db65 100644 --- a/packages/auth/src/features/authenticate/handler.test.ts +++ b/packages/auth/src/features/authenticate/handler.test.ts @@ -68,7 +68,7 @@ describe('authenticate handler receives a request', () => { fetch.mockResponse( JSON.stringify({ userId: '1', - status: 'pending', + status: 'active', scope: ['admin'], mobile: `+345345343` }) @@ -88,5 +88,33 @@ describe('authenticate handler receives a request', () => { expect(spy.mock.calls[0]).toHaveLength(2) expect(spy.mock.calls[0][0]).toBe('+345345343') }) + it('does not generate a mobile verification code for pending users', async () => { + server = await createServerWithEnvironment({ NODE_ENV: 'production' }) + + const reloadedCodeService = require('../verifyCode/service') + + jest.spyOn(reloadedCodeService, 'generateNonce').mockReturnValue('12345') + + fetch.mockResponse( + JSON.stringify({ + userId: '1', + status: 'pending', + scope: ['admin'], + mobile: `+345345343` + }) + ) + const spy = jest.spyOn(reloadedCodeService, 'sendVerificationCode') + + await server.server.inject({ + method: 'POST', + url: '/authenticate', + payload: { + username: '+345345343', + password: '2r23432' + } + }) + + expect(spy).not.toHaveBeenCalled() + }) }) }) diff --git a/packages/auth/src/features/authenticate/handler.ts b/packages/auth/src/features/authenticate/handler.ts index 02df65f563c..543603ad3f0 100644 --- a/packages/auth/src/features/authenticate/handler.ts +++ b/packages/auth/src/features/authenticate/handler.ts @@ -51,10 +51,6 @@ export default async function authenticateHandler( } const nonce = generateNonce() - await storeUserInformation(nonce, result.userId, result.scope, result.mobile) - - await generateAndSendVerificationCode(nonce, result.mobile, result.scope) - const response: IAuthResponse = { mobile: result.mobile, status: result.status, @@ -74,6 +70,15 @@ export default async function authenticateHandler( : WEB_USER_JWT_AUDIENCES, JWT_ISSUER ) + } else { + await storeUserInformation( + nonce, + result.userId, + result.scope, + result.mobile + ) + + await generateAndSendVerificationCode(nonce, result.mobile, result.scope) } return response } diff --git a/packages/resources/src/bgd/features/generate/service.ts b/packages/resources/src/bgd/features/generate/service.ts index 284b3b862c2..359a55b237b 100644 --- a/packages/resources/src/bgd/features/generate/service.ts +++ b/packages/resources/src/bgd/features/generate/service.ts @@ -77,7 +77,7 @@ async function getLocationBBSCode(practionerId: string): Promise { }) } const bbsCode = jurisdictionalLocations.reduce( - (locBBSCode, loc) => locBBSCode.concat(loc.bbsCode || ''), + (locBBSCode, loc) => locBBSCode.concat(loc.bbsCode?.padStart(2, '0') || ''), '' ) diff --git a/packages/resources/src/bgd/features/templates/register.json b/packages/resources/src/bgd/features/templates/register.json index 72e3baf19be..fcb0a29e68f 100644 --- a/packages/resources/src/bgd/features/templates/register.json +++ b/packages/resources/src/bgd/features/templates/register.json @@ -1792,7 +1792,7 @@ "addressKey": "name", "addresses": { "countryCode": "mother.countryPermanent", - "localAddress": "{mother.addressLine4Permanent}, {mother.districtPermanent}, {mother.statePermanent}, {mother.countryPermanent}", + "localAddress": "{mother.addressLine4Permanent}, {mother.districtPermanent}, {mother.statePermanent}", "internationalAddress": "{mother.internationalDistrictPermanent}, {mother.internationalStatePermanent}, {mother.countryPermanent}" } } @@ -2546,16 +2546,16 @@ ], "fonts": { "bn": { - "notosans": { - "normal": "NotoSansBengali-Light.ttf", - "regular": "NotoSansBengali-Light.ttf", - "bold": "NotoSansBengali-Regular.ttf" - }, "notosanscurrency": { "normal": "NotoSansBengali-Light.ttf", "regular": "NotoSansBengali-Light.ttf", "bold": "NotoSansBengali-Light.ttf" }, + "notosans": { + "normal": "NotoSans-Light.ttf", + "regular": "NotoSans-Light.ttf", + "bold": "NotoSans-Regular.ttf" + }, "notosanslocation": { "normal": "NotoSans-Light.ttf", "regular": "NotoSans-Light.ttf", @@ -3940,16 +3940,16 @@ ], "fonts": { "bn": { - "notosans": { - "normal": "NotoSansBengali-Light.ttf", - "regular": "NotoSansBengali-Light.ttf", - "bold": "NotoSansBengali-Regular.ttf" - }, "notosanscurrency": { "normal": "NotoSansBengali-Light.ttf", "regular": "NotoSansBengali-Light.ttf", "bold": "NotoSansBengali-Light.ttf" }, + "notosans": { + "normal": "NotoSans-Light.ttf", + "regular": "NotoSans-Light.ttf", + "bold": "NotoSans-Regular.ttf" + }, "notosanslocation": { "normal": "NotoSans-Light.ttf", "regular": "NotoSans-Light.ttf",