Commit 3feff300 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_payzen: Unauthorized is only raised for anonymous user

In this case, we will allow the super users pay eventually the invoices.
parent 77f4b3b1
from zExceptions import Unauthorized
portal = context.getPortalObject() portal = context.getPortalObject()
person = portal.ERP5Site_getAuthenticatedMemberPersonValue() person = portal.ERP5Site_getAuthenticatedMemberPersonValue()
...@@ -26,7 +27,9 @@ def wrapWithShadow(payment_transaction, person_relative_url): ...@@ -26,7 +27,9 @@ def wrapWithShadow(payment_transaction, person_relative_url):
portal_type="Payzen Event Message")[0].getTextContent() portal_type="Payzen Event Message")[0].getTextContent()
if person is None: if person is None:
return wrapWithShadow(context, context.getDestinationSection()) if not portal.portal_membership.isAnonymousUser():
return wrapWithShadow(context, context.getDestinationSection())
raise Unauthorized("You must be logged in")
return person.Person_restrictMethodAsShadowUser( return person.Person_restrictMethodAsShadowUser(
shadow_document=person, shadow_document=person,
......
...@@ -655,9 +655,11 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -655,9 +655,11 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualPayzenPayment_unauthorzied(self): def test_PaymentTransaction_redirectToManualPayzenPayment_unauthorzied(self):
payment = self.createPaymentTransaction() payment = self.createPaymentTransaction()
self._simulatePaymentTransaction_getVADSUrlDict() self._simulatePaymentTransaction_getVADSUrlDict()
self.logout()
try: try:
self.assertRaises(Unauthorized, payment.PaymentTransaction_redirectToManualPayzenPayment) self.assertRaises(Unauthorized, payment.PaymentTransaction_redirectToManualPayzenPayment)
finally: finally:
self.login()
self._dropPaymentTransaction_getVADSUrlDict() self._dropPaymentTransaction_getVADSUrlDict()
def test_PaymentTransaction_redirectToManualPayzenPayment_redirect(self): def test_PaymentTransaction_redirectToManualPayzenPayment_redirect(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment