def get(self, code): self.response.write("""<form action="/vercap"> """) self.response.write("""<input name="code" type="hidden" value=""" + code + """>""") chtml = captcha.displayhtml(public_key="6LcCYe8SAAAAALsqtQmjcaT_YGMdXUUchvJVoIgN", use_ssl=False, error=None) self.response.write(chtml) self.response.write("""<input type="submit" value="Submit"> """) self.response.write("</form>")
def post(self): f = register_form() captcha_html = captcha.displayhtml(self.settings.CAPTCHA_PUBLIC_KEY, True) captcha_error = '' data = self.get_arguments() _ = self._ if False and data.has_key('username'): existing_user = User.one({'username': data['username']}) f.add_notnull_validator(not existing_user, "The username you wanted is already taken.") try: if f.validates(Storage(data)): #todo use async call captcha_resp = captcha.submit( self.get_argument('recaptcha_challenge_field'), self.get_argument('recaptcha_response_field'), self.settings.CAPTCHA_PRIVATE_KEY, self.request.remote_ip ) if captcha_resp.is_valid: new_user = User() data['is_admin'] = False data['password_hashed'] = unicode(hashlib.sha1(data['password']).hexdigest(), 'utf-8') data['auth_provider'] = u'form' new_user.save(data) self.set_flash(_("You have been successfully registered. ")) self.redirect("/") return captcha_error = captcha_resp.error_code raise Exception("Invalid captcha code") raise InvalidFormDataError(_("Form still have errors.")) except Exception, e: f.note = f.note if f.note else e self.render("register", f=f, captcha_html=captcha_html, captcha_error=captcha_error)
def get(self): f = register_form() captcha_html = captcha.displayhtml(self.settings.CAPTCHA_PUBLIC_KEY, True) self.render("register", f=f, captcha_html=captcha_html, captcha_error='')
def get(self, code): self.response.write("""<form action="/vercap"> """) self.response.write("""<input name="code" type="hidden" value=""" + code + """>""") chtml = captcha.displayhtml( public_key="6LcCYe8SAAAAALsqtQmjcaT_YGMdXUUchvJVoIgN", use_ssl=False, error=None) self.response.write(chtml) self.response.write("""<input type="submit" value="Submit"> """) self.response.write("</form>")
def post(self): f = register_form() captcha_html = captcha.displayhtml(self.settings.CAPTCHA_PUBLIC_KEY, True) captcha_error = '' data = self.get_arguments() _ = self._ if False and data.has_key('username'): existing_user = User.one({'username': data['username']}) f.add_notnull_validator( not existing_user, "The username you wanted is already taken.") try: if f.validates(Storage(data)): #todo use async call captcha_resp = captcha.submit( self.get_argument('recaptcha_challenge_field'), self.get_argument('recaptcha_response_field'), self.settings.CAPTCHA_PRIVATE_KEY, self.request.remote_ip) if captcha_resp.is_valid: new_user = User() data['is_admin'] = False data['password_hashed'] = unicode( hashlib.sha1(data['password']).hexdigest(), 'utf-8') data['auth_provider'] = u'form' new_user.save(data) self.set_flash( _("You have been successfully registered. ")) self.redirect("/") return captcha_error = captcha_resp.error_code raise Exception("Invalid captcha code") raise InvalidFormDataError(_("Form still have errors.")) except Exception, e: f.note = f.note if f.note else e self.render("register", f=f, captcha_html=captcha_html, captcha_error=captcha_error)
def render(self, name, value, attrs=None): return mark_safe(u'%s' % captcha.displayhtml(settings.RECAPTCHA_PUBLIC_KEY))
def get_captcha(self, error): chtml = captcha.displayhtml( public_key=self.get_application().recaptcha_public_key, use_ssl=False, error=error) return chtml
def render(self, name, value, attrs=None): from django.utils.safestring import mark_safe from recaptcha import captcha return mark_safe(u'%s' % captcha.displayhtml(Option.objects.get(key='recaptcha_public_key').value))
def render(self, name, value, attrs=None): return mark_safe("%s" % captcha.displayhtml(settings.RECAPTCHA_PUBLIC_KEY, use_ssl=True))
def get_captcha(self, error): chtml = captcha.displayhtml( public_key = self.get_application().recaptcha_public_key, use_ssl = False, error = error) return chtml