chore: clean-up unsed things in stripe integration (#43156)
* chore: clean-up unsed things in stripe integration * fix: use logged in users email over email given to payment form
This commit is contained in:
@ -14,9 +14,7 @@ export default function getCsurf() {
|
|||||||
const { path } = req;
|
const { path } = req;
|
||||||
if (
|
if (
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
/^\/hooks\/update-paypal$|^\/hooks\/update-stripe$|^\/donate\/charge-stripe$/.test(
|
/^\/hooks\/update-paypal$|^\/donate\/charge-stripe$/.test(path)
|
||||||
path
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
|
@ -23,8 +23,7 @@ const signinRE = /^\/signin/;
|
|||||||
const statusRE = /^\/status\/ping$/;
|
const statusRE = /^\/status\/ping$/;
|
||||||
const unsubscribedRE = /^\/unsubscribed\//;
|
const unsubscribedRE = /^\/unsubscribed\//;
|
||||||
const unsubscribeRE = /^\/u\/|^\/unsubscribe\/|^\/ue\//;
|
const unsubscribeRE = /^\/u\/|^\/unsubscribe\/|^\/ue\//;
|
||||||
const updateHooksRE = /^\/hooks\/update-paypal$|^\/hooks\/update-stripe$/;
|
const updateHooksRE = /^\/hooks\/update-paypal$/;
|
||||||
const createStripeSession = /^\/donate\/create-stripe-session/;
|
|
||||||
// note: this would be replaced by webhooks later
|
// note: this would be replaced by webhooks later
|
||||||
const donateRE = /^\/donate\/charge-stripe$/;
|
const donateRE = /^\/donate\/charge-stripe$/;
|
||||||
|
|
||||||
@ -41,8 +40,7 @@ const _pathsAllowedREs = [
|
|||||||
unsubscribedRE,
|
unsubscribedRE,
|
||||||
unsubscribeRE,
|
unsubscribeRE,
|
||||||
updateHooksRE,
|
updateHooksRE,
|
||||||
donateRE,
|
donateRE
|
||||||
createStripeSession
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export function isAllowedPath(path, pathsAllowedREs = _pathsAllowedREs) {
|
export function isAllowedPath(path, pathsAllowedREs = _pathsAllowedREs) {
|
||||||
|
@ -45,7 +45,7 @@ describe('request-authorization', () => {
|
|||||||
const statusRE = /^\/status\/ping$/;
|
const statusRE = /^\/status\/ping$/;
|
||||||
const unsubscribedRE = /^\/unsubscribed\//;
|
const unsubscribedRE = /^\/unsubscribed\//;
|
||||||
const unsubscribeRE = /^\/u\/|^\/unsubscribe\/|^\/ue\//;
|
const unsubscribeRE = /^\/u\/|^\/unsubscribe\/|^\/ue\//;
|
||||||
const updateHooksRE = /^\/hooks\/update-paypal$|^\/hooks\/update-stripe$/;
|
const updateHooksRE = /^\/hooks\/update-paypal$/;
|
||||||
|
|
||||||
const allowedPathsList = [
|
const allowedPathsList = [
|
||||||
authRE,
|
authRE,
|
||||||
@ -77,11 +77,9 @@ describe('request-authorization', () => {
|
|||||||
allowedPathsList
|
allowedPathsList
|
||||||
);
|
);
|
||||||
const resultC = isAllowedPath('/hooks/update-paypal', allowedPathsList);
|
const resultC = isAllowedPath('/hooks/update-paypal', allowedPathsList);
|
||||||
const resultD = isAllowedPath('/hooks/update-stripe', allowedPathsList);
|
|
||||||
expect(resultA).toBe(true);
|
expect(resultA).toBe(true);
|
||||||
expect(resultB).toBe(true);
|
expect(resultB).toBe(true);
|
||||||
expect(resultC).toBe(true);
|
expect(resultC).toBe(true);
|
||||||
expect(resultD).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns false for a non-white-listed path', () => {
|
it('returns false for a non-white-listed path', () => {
|
||||||
|
@ -191,9 +191,10 @@ class DonateForm extends Component<DonateFormProps, DonateFormState> {
|
|||||||
payerEmail: string | undefined,
|
payerEmail: string | undefined,
|
||||||
payerName: string | undefined
|
payerName: string | undefined
|
||||||
) {
|
) {
|
||||||
|
const { email } = this.props;
|
||||||
const { donationAmount: amount, donationDuration: duration } = this.state;
|
const { donationAmount: amount, donationDuration: duration } = this.state;
|
||||||
|
payerEmail = email ? email : payerEmail;
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
|
|
||||||
// change the donation modal button label to close
|
// change the donation modal button label to close
|
||||||
// or display the close button for the cert donation section
|
// or display the close button for the cert donation section
|
||||||
if (this.props.handleProcessing) {
|
if (this.props.handleProcessing) {
|
||||||
|
Reference in New Issue
Block a user