Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place Order controller will hide/overwrite errors from other entries in the chain #19

Open
moorena opened this issue Apr 2, 2025 · 0 comments

Comments

@moorena
Copy link

moorena commented Apr 2, 2025

server.append('PlaceOrder', server.middleware.https, function (req, res, next) {
// eslint-disable-next-line no-undef
if (session.privacy.AuthorizeErrors) {
// eslint-disable-next-line no-undef
var message = session.privacy.AuthorizeErrors;
try {
var messageObject = JSON.parse(message);
if ('message' in messageObject) {
message = messageObject.message;
}
// eslint-disable-next-line no-empty
} catch (e) { }
res.json({
error: true,
errorMessage: message
});
// eslint-disable-next-line no-undef
delete session.privacy.AuthorizeErrors;
} else {
//For Googlepay and Visa Checkeout Redirect to COPlaceOrder-SubmitOrderConformation.
res.json({
error: false,
ID: session.privacy.orderID,
token: session.privacy.orderToken,
continueUrl: URLUtils.url('COPlaceOrder-SubmitOrderConformation').toString()
});
}
return next();
});

The code here does not respect previous errors -- it does not test viewdata.error/res.error that may have been set in a previous controller in the chain -- and instead will (if there is no authorization errors) overwrite the existing value and claim "no errors". That is ... not good..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant