Skip to content

Commit

Permalink
Merge pull request #1443 from jembi/prod-issues
Browse files Browse the repository at this point in the history
Fixes for some production issues
  • Loading branch information
euanmillar authored Jan 14, 2020
2 parents 815a07f + ee2b313 commit 07ca632
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 17 deletions.
30 changes: 29 additions & 1 deletion packages/auth/src/features/authenticate/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('authenticate handler receives a request', () => {
fetch.mockResponse(
JSON.stringify({
userId: '1',
status: 'pending',
status: 'active',
scope: ['admin'],
mobile: `+345345343`
})
Expand All @@ -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()
})
})
})
13 changes: 9 additions & 4 deletions packages/auth/src/features/authenticate/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion packages/resources/src/bgd/features/generate/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async function getLocationBBSCode(practionerId: string): Promise<string> {
})
}
const bbsCode = jurisdictionalLocations.reduce(
(locBBSCode, loc) => locBBSCode.concat(loc.bbsCode || ''),
(locBBSCode, loc) => locBBSCode.concat(loc.bbsCode?.padStart(2, '0') || ''),
''
)

Expand Down
22 changes: 11 additions & 11 deletions packages/resources/src/bgd/features/templates/register.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 07ca632

Please sign in to comment.