added currentUserID to delete payment method
MODIFY
src/server/rest/v1/service/BillingService.ts
src/server/rest/v1/service/BillingService.ts
@@ -579,8 +579,7 @@ export default class BillingService {
user: req.user
});
}
- // Get user - TODO - userID should come from the filteredRequest not from the userToken
- const userID = req.user.id;
+ const userID = filteredRequest.userID;
const user: User = await UserStorage.getUser(req.user.tenantID, userID);
UtilsService.assertObjectExists(action, user, `User '${userID}' does not exist`,
MODULE_NAME, 'handleBillingDeletePaymentMethod', req.user);

MODIFY
src/server/rest/v1/service/security/BillingSecurity.ts
src/server/rest/v1/service/security/BillingSecurity.ts
@@ -81,8 +81,7 @@ export default class BillingSecurity {
static filterDeletePaymentMethodRequest(requestBody: any): HttpDeletePaymentMethod {
return {
- // TODO - The UI cannot pass the userID so far - so we can only delete payment method for the user being logged in!
- // userID: sanitize(requestBody.userID),
+ userID: sanitize(requestBody.userID),
paymentMethodId: sanitize(requestBody.paymentMethodId),
};
}

MODIFY
src/types/requests/HttpBillingRequest.ts
src/types/requests/HttpBillingRequest.ts
@@ -26,6 +26,6 @@ export interface HttpPaymentMethods {
}
export interface HttpDeletePaymentMethod {
- // userID: string;
+ userID: string;
paymentMethodId: string;
}

added currentUserID to delete payment method