Ejemplo n.º 1
0
def lobby(request):
    if request.GET.get('req'):
        # If it returns a response there was likely
        # an error and we should return it.
        res = process_pay_req(request)
        if isinstance(res, http.HttpResponse):
            return res
    elif not 'notes' in request.session:
        return _error(request, msg='req is required')

    pin_form = VerifyPinForm()
    pin_form.pin_recently_entered = pin_recently_entered(request)

    return render(request, 'pay/lobby.html', {'form': pin_form,
                  'title': _('Enter your PIN:')})
Ejemplo n.º 2
0
def lobby(request):
    if request.GET.get('req'):
        # If it returns a response there was likely
        # an error and we should return it.
        res = process_pay_req(request)
        if isinstance(res, http.HttpResponse):
            return res
    elif settings.TEST_PIN_UI:
        # This won't get you very far but it lets you create/enter PINs
        # and stops a traceback after that.
        request.session['trans_id'] = uuid.uuid4()
    elif not 'notes' in request.session:
        # A JWT was not passed in and no JWT is in the session.
        return _error(request, msg='req is required')

    pin_form = VerifyPinForm()
    sess = request.session

    if pin_recently_entered(request):
        return http.HttpResponseRedirect(get_payment_url())

    # 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.
    if sess.get('uuid_needs_pin_reset'):
        solitude.set_needs_pin_reset(sess['uuid'], False)
        sess['uuid_needs_pin_reset'] = False

    if sess.get('is_simulation', False):
        sim_req = sess['notes']['pay_request']['request']['simulate']
        log.info('Starting simulate %s for %s'
                 % (sim_req, sess['notes']['issuer_key']))
        return render(request, 'pay/simulate.html', {
            'simulate': sim_req
        })

    return render(request, 'pay/lobby.html', {
        'action': reverse('pin.verify'),
        'form': pin_form,
        'title': _('Enter Pin')
    })
Ejemplo n.º 3
0
 def test_pin_entered_after_timeout(self):
     self.request.session["last_pin_success"] = datetime.now() - timedelta(seconds=settings.PIN_UNLOCK_LENGTH + 60)
     assert not utils.pin_recently_entered(self.request)
Ejemplo n.º 4
0
 def test_pin_recenlty_entered_successfully(self):
     self.request.session["last_pin_success"] = datetime.now()
     assert utils.pin_recently_entered(self.request)
Ejemplo n.º 5
0
 def test_pin_never_entered(self):
     assert not utils.pin_recently_entered(self.request)