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')) # Before we continue with the buy flow, let's save some # time and get the transaction configured via Bango in the # background. configure_transaction(request) 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') })
def start(self, marketplace, solitude, locale=None, session=None, request=None): if session is None: session = {} prices = mock.Mock() prices.get_object.return_value = self.prices marketplace.webpay.prices.return_value = prices solitude.get_transaction.return_value = { 'status': constants.STATUS_CANCELLED, 'notes': self.notes, 'type': constants.TYPE_PAYMENT, 'uuid': self.transaction_uuid } if request is None: request = RequestFactory().get('/') if locale: request.locale = locale request.session = session request.session['trans_id'] = self.transaction_uuid request.session['notes'] = self.notes request.session['is_simulation'] = False request.session['uuid'] = self.user_uuid return tasks.configure_transaction(request)
def verify(request): form = BrowserIDForm(data=request.POST) if form.is_valid(): url = settings.BROWSERID_VERIFICATION_URL audience = get_audience(request) extra_params = { 'experimental_forceIssuer': settings.BROWSERID_UNVERIFIED_ISSUER, 'experimental_allowUnverified': 'true' } assertion = form.cleaned_data['assertion'] log.info('verifying Persona assertion. url: %s, audience: %s, ' 'extra_params: %s, assertion: %s' % (url, audience, extra_params, assertion)) result = verify_assertion(assertion, audience, extra_params) if result: log.info('Persona assertion ok: %s' % result) email = result.get('unverified-email', result.get('email')) store_mkt_permissions(request, email, assertion, audience) user_uuid = set_user(request, email) redirect_url = check_pin_status(request) # Before we verify the user's PIN let's save some # time and get the transaction configured via Bango in the # background. log.info('configuring transaction {0} from auth'.format( request.session.get('trans_id'))) pay_tasks.configure_transaction(request) return { 'needs_redirect': redirect_url is not None, 'redirect_url': redirect_url, 'user_hash': user_uuid } log.error('Persona assertion failed.') request.session.flush() return http.HttpResponseBadRequest()
def verify(request): form = BrowserIDForm(data=request.POST) if form.is_valid(): url = settings.BROWSERID_VERIFICATION_URL audience = get_audience(request) extra_params = { 'experimental_forceIssuer': settings.BROWSERID_UNVERIFIED_ISSUER, 'experimental_allowUnverified': 'true' } assertion = form.cleaned_data['assertion'] log.info('verifying Persona assertion. url: %s, audience: %s, ' 'extra_params: %s, assertion: %s' % (url, audience, extra_params, assertion)) result = verify_assertion(assertion, audience, extra_params) if result: log.info('Persona assertion ok: %s' % result) email = result.get('unverified-email', result.get('email')) store_mkt_permissions(request, email, assertion, audience) user_uuid = set_user(request, email) redirect_url = check_pin_status(request) # Before we verify the user's PIN let's save some # time and get the transaction configured via Bango in the # background. log.info('configuring transaction {0} from auth' .format(request.session.get('trans_id'))) pay_tasks.configure_transaction(request) return { 'needs_redirect': redirect_url is not None, 'redirect_url': redirect_url, 'user_hash': user_uuid } log.error('Persona assertion failed.') request.session.flush() return http.HttpResponseBadRequest()
def start(self, marketplace, solitude, locale=None, session=None): if session is None: session = {} prices = mock.Mock() prices.get_object.return_value = self.prices marketplace.webpay.prices.return_value = prices solitude.get_transaction.return_value = { 'status': constants.STATUS_CANCELLED, 'notes': self.notes, 'type': constants.TYPE_PAYMENT, 'uuid': self.transaction_uuid } request = RequestFactory().get('/') if locale: request.locale = locale request.session = session request.session['trans_id'] = self.transaction_uuid request.session['notes'] = self.notes request.session['is_simulation'] = False request.session['uuid'] = self.user_uuid tasks.configure_transaction(request)
def verify(request): form = BrowserIDForm(data=request.POST) if form.is_valid(): url = settings.BROWSERID_VERIFICATION_URL audience = get_audience(request) extra_params = { "experimental_forceIssuer": settings.BROWSERID_UNVERIFIED_ISSUER, "experimental_allowUnverified": "true", } assertion = form.cleaned_data["assertion"] log.info( "verifying Persona assertion. url: %s, audience: %s, " "extra_params: %s, assertion: %s" % (url, audience, extra_params, assertion) ) result = verify_assertion(assertion, audience, extra_params) if result: log.info("Persona assertion ok: %s" % result) email = result.get("unverified-email", result.get("email")) store_mkt_permissions(request, email, assertion, audience) user_uuid = set_user(request, email) redirect_url = check_pin_status(request) # Before we verify the user's PIN let's save some # time and get the transaction configured via Bango in the # background. log.info("configuring transaction {0} from auth".format(request.session.get("trans_id"))) pay_tasks.configure_transaction(request) return {"needs_redirect": redirect_url is not None, "redirect_url": redirect_url, "user_hash": user_uuid} log.error("Persona assertion failed.") request.session.flush() return http.HttpResponseBadRequest()
def configure(self, get_trans): get_trans.side_effect = ObjectDoesNotExist return tasks.configure_transaction(self.request)
def configure(self): tasks.configure_transaction(self.request)