Skip to content
This repository has been archived by the owner on Jan 25, 2018. It is now read-only.

Commit

Permalink
pass proper arguments to change_pin (bug 868101)
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithan committed May 21, 2013
1 parent 767cf68 commit 777a2e6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions webpay/pay/tests/test_views.py
Expand Up @@ -121,6 +121,10 @@ def test_recently_entered_pin_redirect(self, get_price,
def test_reset_flag_true(self, set_needs_pin_reset,
get_price, get_active_product):
self.set_secret(get_active_product)
# To appease has_pin
self.session['uuid_has_pin'] = True
self.session['uuid_has_confirmed_pin'] = True

self.session['uuid_needs_pin_reset'] = True
self.session['uuid'] = 'some:uuid'
self.session.save()
Expand Down
5 changes: 4 additions & 1 deletion webpay/pay/views.py
Expand Up @@ -16,7 +16,7 @@
from webpay.base.decorators import json_view
from webpay.base.utils import _error
from webpay.pin.forms import VerifyPinForm
from webpay.pin.utils import pin_recently_entered
from webpay.pin.utils import has_pin, pin_recently_entered

from lib.marketplace.api import client as marketplace, UnknownPricePoint
from lib.solitude import constants
Expand Down Expand Up @@ -117,6 +117,9 @@ def lobby(request):
if pin_recently_entered(request):
return http.HttpResponseRedirect(get_payment_url())

if sess.get('uuid') and not has_pin(request):
return http.HttpResponseRedirect(reverse('pin.create'))

# If the buyer closed the trusted UI during reset flow, we want to unset
# the reset pin flag. They can hit the forgot pin button if they still
# don't remember their pin.
Expand Down
2 changes: 1 addition & 1 deletion webpay/pin/forms.py
Expand Up @@ -59,7 +59,7 @@ def clean_pin(self, *args, **kwargs):
pin = self.cleaned_data['pin']
buyer = client.get_buyer(self.uuid)
if buyer and self.handle_client_errors(buyer):
self.buyer = buyer
self.buyer_exists = True
if buyer.get('pin'):
raise forms.ValidationError(
_('You have already created a PIN.')
Expand Down
4 changes: 2 additions & 2 deletions webpay/pin/views.py
Expand Up @@ -26,8 +26,8 @@ def create(request):
if request.method == 'POST':
form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
if form.is_valid():
if hasattr(form, 'buyer'):
res = client.change_pin(form.buyer, form.cleaned_data['pin'])
if getattr(form, 'buyer_exists', False):
res = client.change_pin(form.uuid, form.cleaned_data['pin'])
else:
res = client.create_buyer(form.uuid, form.cleaned_data['pin'])
if form.handle_client_errors(res):
Expand Down

0 comments on commit 777a2e6

Please sign in to comment.