Skip to content

Commit 07ca632

Browse files
authored
Merge pull request #1443 from jembi/prod-issues
Fixes for some production issues
2 parents 815a07f + ee2b313 commit 07ca632

File tree

4 files changed

+50
-17
lines changed

4 files changed

+50
-17
lines changed

packages/auth/src/features/authenticate/handler.test.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('authenticate handler receives a request', () => {
6868
fetch.mockResponse(
6969
JSON.stringify({
7070
userId: '1',
71-
status: 'pending',
71+
status: 'active',
7272
scope: ['admin'],
7373
mobile: `+345345343`
7474
})
@@ -88,5 +88,33 @@ describe('authenticate handler receives a request', () => {
8888
expect(spy.mock.calls[0]).toHaveLength(2)
8989
expect(spy.mock.calls[0][0]).toBe('+345345343')
9090
})
91+
it('does not generate a mobile verification code for pending users', async () => {
92+
server = await createServerWithEnvironment({ NODE_ENV: 'production' })
93+
94+
const reloadedCodeService = require('../verifyCode/service')
95+
96+
jest.spyOn(reloadedCodeService, 'generateNonce').mockReturnValue('12345')
97+
98+
fetch.mockResponse(
99+
JSON.stringify({
100+
userId: '1',
101+
status: 'pending',
102+
scope: ['admin'],
103+
mobile: `+345345343`
104+
})
105+
)
106+
const spy = jest.spyOn(reloadedCodeService, 'sendVerificationCode')
107+
108+
await server.server.inject({
109+
method: 'POST',
110+
url: '/authenticate',
111+
payload: {
112+
username: '+345345343',
113+
password: '2r23432'
114+
}
115+
})
116+
117+
expect(spy).not.toHaveBeenCalled()
118+
})
91119
})
92120
})

packages/auth/src/features/authenticate/handler.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ export default async function authenticateHandler(
5151
}
5252

5353
const nonce = generateNonce()
54-
await storeUserInformation(nonce, result.userId, result.scope, result.mobile)
55-
56-
await generateAndSendVerificationCode(nonce, result.mobile, result.scope)
57-
5854
const response: IAuthResponse = {
5955
mobile: result.mobile,
6056
status: result.status,
@@ -74,6 +70,15 @@ export default async function authenticateHandler(
7470
: WEB_USER_JWT_AUDIENCES,
7571
JWT_ISSUER
7672
)
73+
} else {
74+
await storeUserInformation(
75+
nonce,
76+
result.userId,
77+
result.scope,
78+
result.mobile
79+
)
80+
81+
await generateAndSendVerificationCode(nonce, result.mobile, result.scope)
7782
}
7883
return response
7984
}

packages/resources/src/bgd/features/generate/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async function getLocationBBSCode(practionerId: string): Promise<string> {
7777
})
7878
}
7979
const bbsCode = jurisdictionalLocations.reduce(
80-
(locBBSCode, loc) => locBBSCode.concat(loc.bbsCode || ''),
80+
(locBBSCode, loc) => locBBSCode.concat(loc.bbsCode?.padStart(2, '0') || ''),
8181
''
8282
)
8383

packages/resources/src/bgd/features/templates/register.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@
17921792
"addressKey": "name",
17931793
"addresses": {
17941794
"countryCode": "mother.countryPermanent",
1795-
"localAddress": "{mother.addressLine4Permanent}, {mother.districtPermanent}, {mother.statePermanent}, {mother.countryPermanent}",
1795+
"localAddress": "{mother.addressLine4Permanent}, {mother.districtPermanent}, {mother.statePermanent}",
17961796
"internationalAddress": "{mother.internationalDistrictPermanent}, {mother.internationalStatePermanent}, {mother.countryPermanent}"
17971797
}
17981798
}
@@ -2546,16 +2546,16 @@
25462546
],
25472547
"fonts": {
25482548
"bn": {
2549-
"notosans": {
2550-
"normal": "NotoSansBengali-Light.ttf",
2551-
"regular": "NotoSansBengali-Light.ttf",
2552-
"bold": "NotoSansBengali-Regular.ttf"
2553-
},
25542549
"notosanscurrency": {
25552550
"normal": "NotoSansBengali-Light.ttf",
25562551
"regular": "NotoSansBengali-Light.ttf",
25572552
"bold": "NotoSansBengali-Light.ttf"
25582553
},
2554+
"notosans": {
2555+
"normal": "NotoSans-Light.ttf",
2556+
"regular": "NotoSans-Light.ttf",
2557+
"bold": "NotoSans-Regular.ttf"
2558+
},
25592559
"notosanslocation": {
25602560
"normal": "NotoSans-Light.ttf",
25612561
"regular": "NotoSans-Light.ttf",
@@ -3940,16 +3940,16 @@
39403940
],
39413941
"fonts": {
39423942
"bn": {
3943-
"notosans": {
3944-
"normal": "NotoSansBengali-Light.ttf",
3945-
"regular": "NotoSansBengali-Light.ttf",
3946-
"bold": "NotoSansBengali-Regular.ttf"
3947-
},
39483943
"notosanscurrency": {
39493944
"normal": "NotoSansBengali-Light.ttf",
39503945
"regular": "NotoSansBengali-Light.ttf",
39513946
"bold": "NotoSansBengali-Light.ttf"
39523947
},
3948+
"notosans": {
3949+
"normal": "NotoSans-Light.ttf",
3950+
"regular": "NotoSans-Light.ttf",
3951+
"bold": "NotoSans-Regular.ttf"
3952+
},
39533953
"notosanslocation": {
39543954
"normal": "NotoSans-Light.ttf",
39553955
"regular": "NotoSans-Light.ttf",

0 commit comments

Comments
 (0)