fix(payments): only checkIpOnly if no credentials

Because:

* For the invoice preview endpoint, for logged in users, do not perform
  the customs.checkIpOnly.

This commit:

* Only performs the customs.checkIpOnly check if auth credentials are
  not provided.

Closes FXA-6543
This commit is contained in:
Reino Muhl 2022-12-28 12:58:48 -05:00
Родитель 814abfed58
Коммит 220b6f77d6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: C86660FCF998897A
2 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -415,7 +415,6 @@ export class StripeHandler {
request: AuthRequest
): Promise<invoiceDTO.firstInvoicePreviewSchema> {
this.log.begin('subscriptions.previewInvoice', request);
await this.customs.checkIpOnly(request, 'previewInvoice');
const { promotionCode, priceId } = request.payload as Record<
string,
@ -431,6 +430,8 @@ export class StripeHandler {
} catch (e: any) {
this.log.error('previewInvoice.fetchCustomer', { error: e, uid });
}
} else {
await this.customs.checkIpOnly(request, 'previewInvoice');
}
const country = request.app.geo.location?.country || 'US';

Просмотреть файл

@ -665,8 +665,9 @@ describe('DirectStripeRoutes', () => {
VALID_REQUEST
);
sinon.assert.calledOnceWithExactly(
directStripeRoutesInstance.customs.checkIpOnly,
directStripeRoutesInstance.customs.check,
VALID_REQUEST,
TEST_EMAIL,
'previewInvoice'
);
sinon.assert.calledOnceWithExactly(
@ -707,8 +708,9 @@ describe('DirectStripeRoutes', () => {
VALID_REQUEST
);
sinon.assert.calledOnceWithExactly(
directStripeRoutesInstance.customs.checkIpOnly,
directStripeRoutesInstance.customs.check,
VALID_REQUEST,
TEST_EMAIL,
'previewInvoice'
);
sinon.assert.calledOnceWithExactly(
@ -747,8 +749,9 @@ describe('DirectStripeRoutes', () => {
);
sinon.assert.calledOnceWithExactly(
directStripeRoutesInstance.customs.checkIpOnly,
directStripeRoutesInstance.customs.check,
VALID_REQUEST,
TEST_EMAIL,
'previewInvoice'
);
sinon.assert.calledOnceWithExactly(