Пример #1
0
def reset_cancel(request):
    try:
        client.set_needs_pin_reset(get_user(request), False)
    except ResourceModified:
        return system_error(request, code=msg.RESOURCE_MODIFIED)
    request.session['uuid_needs_pin_reset'] = False
    return http.HttpResponseRedirect(reverse('pin.verify'))
Пример #2
0
def reset_cancel(request):
    try:
        client.set_needs_pin_reset(get_user(request), False)
    except ResourceModified:
        return system_error(request, code=msg.RESOURCE_MODIFIED)
    request.session['uuid_needs_pin_reset'] = False
    return http.HttpResponseRedirect(reverse('pin.verify'))
Пример #3
0
def lobby(request):
    sess = request.session
    trans = None

    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'] = trans_id()
    elif not sess.get('is_simulation', False):
        try:
            trans = solitude.get_transaction(request.session.get('trans_id'))
        except ObjectDoesNotExist:
            if request.session.get('trans_id'):
                log.info('Attempted to restart non-existent transaction {0}'
                         .format(request.session.get('trans_id')))
            return _error(request, msg='req is required')

    pin_form = VerifyPinForm()

    if sess.get('uuid'):
        auth_utils.update_session(request, sess.get('uuid'))

        # Before we continue with the buy flow, let's save some
        # time and get the transaction configured via Bango in the
        # background.
        log.info('configuring transaction {0} from lobby'
                 .format(request.session.get('trans_id')))
        tasks.configure_transaction(request, trans=trans)

        redirect_url = check_pin_status(request)
        if redirect_url is not None:
            return http.HttpResponseRedirect(redirect_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')
    })
Пример #4
0
def lobby(request):
    sess = request.session
    trans = None

    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.
        sess['trans_id'] = trans_id()
    elif not sess.get('is_simulation', False):
        try:
            trans = solitude.get_transaction(sess.get('trans_id'))
        except ObjectDoesNotExist:
            if sess.get('trans_id'):
                log.info(
                    'Attempted to restart non-existent transaction {0}'.format(
                        sess.get('trans_id')))
            return _error(request, msg='req is required')

    pin_form = VerifyPinForm()

    if sess.get('uuid'):
        auth_utils.update_session(request, sess.get('uuid'), False)

        # Before we continue with the buy flow, let's save some
        # time and get the transaction configured via Bango in the
        # background.
        log.info('configuring transaction {0} from lobby'.format(
            sess.get('trans_id')))
        tasks.configure_transaction(request, trans=trans)

        redirect_url = check_pin_status(request)
        if redirect_url is not None:
            return http.HttpResponseRedirect('{0}?next={1}'.format(
                reverse('pay.bounce'), redirect_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')
    })
Пример #5
0
 def test_unset_needs_pin_reset_with_wrong_etag(self, slumber):
     wrong_etag = 'etag:wrong'
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.side_effect = HttpClientError(
         response=self.create_error_response(
             status_code=412, content={'ERROR': ['RESOURCE_MODIFIED']}))
     slumber.generic.buyer.return_value = buyer
     with self.assertRaises(ResourceModified):
         client.set_needs_pin_reset(self.uuid, False, etag=wrong_etag)
Пример #6
0
def reset_start(request):
    client.set_needs_pin_reset(get_user(request))
    request.session['uuid_needs_pin_reset'] = True
    form = forms.CreatePinForm()
    form.reset_flow = True
    return render(request, 'pin/reset_start.html',
                  {'title': _('Reset Pin'),
                   'action': reverse('pin.reset_new_pin'),
                   'form': form})
Пример #7
0
def lobby(request):
    sess = request.session
    have_jwt = bool(request.GET.get('req'))

    log.info('starting from JWT? {have_jwt}'.format(have_jwt=have_jwt))
    if have_jwt:
        # 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.
        sess['trans_id'] = trans_id()

    pin_form = VerifyPinForm()

    if sess.get('uuid'):
        auth_utils.update_session(request,
                                  sess.get('uuid'),
                                  False,
                                  request.session.get('logged_in_user', None))

        redirect_url = check_pin_status(request)
        if redirect_url is not None:
            return http.HttpResponseRedirect(
                '{0}?next={1}'.format(reverse('pay.bounce'), redirect_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'):
        try:
            solitude.set_needs_pin_reset(sess['uuid'], False)
        except ResourceModified:
            return system_error(request, code=msg.RESOURCE_MODIFIED)
        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'),
        'track_cancel': {
            'action': 'pin cancel',
            'label': 'Pin Entry Page',
        },
    })
Пример #8
0
def reset_start(request):
    request.session['was_reverified'] = False
    client.set_needs_pin_reset(get_user(request))
    request.session['uuid_needs_pin_reset'] = True
    form = forms.CreatePinForm()
    form.reset_flow = True
    return render(request, 'pin/reset_start.html',
                  {'title': _('Reset Pin'),
                   'action': reverse('pin.reset_new_pin'),
                   'form': form})
Пример #9
0
 def test_unset_needs_pin_reset_with_wrong_etag(self, slumber):
     wrong_etag = 'etag:wrong'
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.side_effect = HttpClientError(
         response=self.create_error_response(
             status_code=412,
             content={'ERROR': ['RESOURCE_MODIFIED']}))
     slumber.generic.buyer.return_value = buyer
     with self.assertRaises(ResourceModified):
         client.set_needs_pin_reset(self.uuid, False, etag=wrong_etag)
Пример #10
0
    def test_reset_pin_flag_set(self):
        # set
        res = client.set_needs_pin_reset(self.uuid)
        eq_(res, {})
        buyer = client.get_buyer(self.uuid)
        assert buyer['needs_pin_reset']

        # unset
        res = client.set_needs_pin_reset(self.uuid, False)
        eq_(res, {})
        buyer = client.get_buyer(self.uuid)
        assert not buyer['needs_pin_reset']
Пример #11
0
def lobby(request):
    sess = request.session
    have_jwt = bool(request.GET.get('req'))

    log.info('starting from JWT? {have_jwt}'.format(have_jwt=have_jwt))
    if have_jwt:
        # 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.
        sess['trans_id'] = trans_id()

    pin_form = VerifyPinForm()

    if sess.get('uuid'):
        auth_utils.update_session(request, sess.get('uuid'), False)

        redirect_url = check_pin_status(request)
        if redirect_url is not None:
            return http.HttpResponseRedirect('{0}?next={1}'.format(
                reverse('pay.bounce'), redirect_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'):
        try:
            solitude.set_needs_pin_reset(sess['uuid'], False)
        except ResourceModified:
            return system_error(request, code=msg.RESOURCE_MODIFIED)
        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'),
            'track_cancel': {
                'action': 'pin cancel',
                'label': 'Pin Entry Page',
            },
        })
Пример #12
0
def reset_start(request):
    request.session['was_reverified'] = False
    client.set_needs_pin_reset(get_user(request))
    request.session['uuid_needs_pin_reset'] = True
    form = forms.CreatePinForm()
    form.reset_flow = True
    return render(request, 'pin/reset_start.html',
                  {'title': _('Reset Pin'),
                   'action': reverse('pin.reset_new_pin'),
                   'form': form,
                   'track_cancel': {
                       'action': 'pin cancel',
                       'label': 'Reset Start Page',
                   }})
Пример #13
0
def lobby(request):
    sess = request.session
    have_jwt = bool(request.GET.get("req"))

    log.info("starting from JWT? {have_jwt}".format(have_jwt=have_jwt))
    if have_jwt:
        # 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.
        sess["trans_id"] = trans_id()

    pin_form = VerifyPinForm()

    if sess.get("uuid"):
        auth_utils.update_session(request, sess.get("uuid"), False)

        redirect_url = check_pin_status(request)
        if redirect_url is not None:
            return http.HttpResponseRedirect("{0}?next={1}".format(reverse("pay.bounce"), redirect_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"):
        try:
            solitude.set_needs_pin_reset(sess["uuid"], False)
        except ResourceModified:
            return system_error(request, code=msg.RESOURCE_MODIFIED)
        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"),
            "track_cancel": {"action": "pin cancel", "label": "Pin Entry Page"},
        },
    )
Пример #14
0
 def test_unset_needs_pin_reset_with_good_etag(self, slumber):
     etag = 'etag:good'
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.return_value = {}
     slumber.generic.buyer.return_value = buyer
     res = client.set_needs_pin_reset(self.uuid, False, etag=etag)
     eq_(res, {})
Пример #15
0
    def test_reset_pin_flag_set(self):
        # set
        client.set_new_pin(self.uuid, '1234')
        res = client.set_needs_pin_reset(self.uuid)
        eq_(res, {})
        buyer = client.get_buyer(self.uuid)
        assert buyer['needs_pin_reset']
        assert not buyer['new_pin']

        # unset
        client.set_new_pin(self.uuid, '1234')
        res = client.set_needs_pin_reset(self.uuid, False)
        eq_(res, {})
        buyer = client.get_buyer(self.uuid)
        assert not buyer['needs_pin_reset']
        assert not buyer['new_pin']
Пример #16
0
    def test_reset_pin_flag_set(self):
        # set
        client.set_new_pin(self.uuid, "1234")
        res = client.set_needs_pin_reset(self.uuid)
        eq_(res, {})
        buyer = client.get_buyer(self.uuid)
        assert buyer["needs_pin_reset"]
        assert not buyer["new_pin"]

        # unset
        client.set_new_pin(self.uuid, "1234")
        res = client.set_needs_pin_reset(self.uuid, False)
        eq_(res, {})
        buyer = client.get_buyer(self.uuid)
        assert not buyer["needs_pin_reset"]
        assert not buyer["new_pin"]
Пример #17
0
 def test_unset_needs_pin_reset_with_good_etag(self, slumber):
     etag = 'etag:good'
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.return_value = {}
     slumber.generic.buyer.return_value = buyer
     res = client.set_needs_pin_reset(self.uuid, False, etag=etag)
     eq_(res, {})
Пример #18
0
def reset_start(request):
    request.session['was_reverified'] = False
    try:
        client.set_needs_pin_reset(get_user(request))
    except ResourceModified:
        return system_error(request, code=msg.RESOURCE_MODIFIED)
    request.session['uuid_needs_pin_reset'] = True
    form = forms.CreatePinForm()
    form.reset_flow = True
    return render(request, 'pin/reset_start.html',
                  {'title': _('Reset Pin'),
                   'action': reverse('pin.reset_new_pin'),
                   'form': form,
                   'track_cancel': {
                       'action': 'pin cancel',
                       'label': 'Reset Start Page',
                   }})
Пример #19
0
def reset_start(request):
    request.session['was_reverified'] = False
    try:
        client.set_needs_pin_reset(get_user(request))
    except ResourceModified:
        return system_error(request, code=msg.RESOURCE_MODIFIED)
    request.session['uuid_needs_pin_reset'] = True
    form = forms.CreatePinForm()
    form.reset_flow = True
    return render(
        request, 'pin/reset_start.html', {
            'title': _('Reset Pin'),
            'action': reverse('pin.reset_new_pin'),
            'form': form,
            'track_cancel': {
                'action': 'pin cancel',
                'label': 'Reset Start Page',
            }
        })
Пример #20
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 sess.get('uuid'):
        auth_utils.update_session(request, sess.get('uuid'))
        redirect_url = check_pin_status(request)
        if redirect_url is not None:
            return http.HttpResponseRedirect(redirect_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')
    })
Пример #21
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')
    })
Пример #22
0
 def test_unset_needs_pin_reset_with_wrong_etag(self, slumber):
     wrong_etag = 'etag:wrong'
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.side_effect = HttpClientError(
         response=self.create_error_response(
             status_code=412,
             content={'ERROR': [('The resource has been modified, '
                                       'please re-fetch it.')]}))
     slumber.generic.buyer.return_value = buyer
     res = client.set_needs_pin_reset(self.uuid, False, etag=wrong_etag)
     assert 'errors' in res
     eq_(res['errors'],
     [ERROR_STRINGS['The resource has been modified, please re-fetch it.']])
Пример #23
0
def reset_start(request):
    # TODO(Wraithan): Create dialog to make sure you meant to reset your pin
    client.set_needs_pin_reset(get_user(request))
    return http.HttpResponseRedirect(reverse("auth.logout"))
Пример #24
0
def reset_cancel(request):
    client.set_needs_pin_reset(get_user(request), False)
    request.session['uuid_needs_pin_reset'] = False
    return http.HttpResponseRedirect(reverse('pin.verify'))
Пример #25
0
def reset_cancel(request):
    client.set_needs_pin_reset(get_user(request), False)
    return http.HttpResponseRedirect(reverse("pin.verify"))
Пример #26
0
                 .format(sess.get('trans_id')))
        if not tasks.configure_transaction(request, trans=trans):
            log.error('Configuring transaction failed.')

        redirect_url = check_pin_status(request)
        if redirect_url is not None:
            return http.HttpResponseRedirect(
                '{0}?next={1}'.format(reverse('pay.bounce'), redirect_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'):
        try:
            solitude.set_needs_pin_reset(sess['uuid'], False)
        except ResourceModified:
            return system_error(request, code=msg.RESOURCE_MODIFIED)
        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,
Пример #27
0
def reset_cancel(request):
    client.set_needs_pin_reset(get_user(request), False)
    request.session['uuid_needs_pin_reset'] = False
    return http.HttpResponseRedirect(reverse('pin.verify'))
Пример #28
0
 def test_unset_needs_pin_reset(self, slumber):
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.return_value = {}
     slumber.generic.buyer.return_value = buyer
     res = client.set_needs_pin_reset(self.uuid, False)
     eq_(res, {})
Пример #29
0
 def test_unset_needs_pin_reset(self, slumber):
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.return_value = {}
     slumber.generic.buyer.return_value = buyer
     res = client.set_needs_pin_reset(self.uuid, False)
     eq_(res, {})