コード例 #1
0
ファイル: main.py プロジェクト: rhsu14/FoodApp_android
 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>")
コード例 #2
0
ファイル: auth.py プロジェクト: apit/rinjani
    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)
コード例 #3
0
 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='')
コード例 #4
0
ファイル: main.py プロジェクト: rhsu14/FoodApp_android
 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>")
コード例 #5
0
    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)
コード例 #6
0
 def render(self, name, value, attrs=None):
     return mark_safe(u'%s' % captcha.displayhtml(settings.RECAPTCHA_PUBLIC_KEY))
コード例 #7
0
 def get_captcha(self, error):
     chtml = captcha.displayhtml(
         public_key=self.get_application().recaptcha_public_key,
         use_ssl=False,
         error=error)
     return chtml
コード例 #8
0
 def render(self, name, value, attrs=None):
     return mark_safe(u'%s' %
                      captcha.displayhtml(settings.RECAPTCHA_PUBLIC_KEY))
コード例 #9
0
ファイル: auth.py プロジェクト: apit/rinjani
 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='')
コード例 #10
0
    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))
コード例 #11
0
ファイル: widgets.py プロジェクト: kennydo/ocf-account-tools
 def render(self, name, value, attrs=None):
     return mark_safe("%s" % captcha.displayhtml(settings.RECAPTCHA_PUBLIC_KEY, use_ssl=True))
コード例 #12
0
	def get_captcha(self, error):
		chtml = captcha.displayhtml(
			public_key = self.get_application().recaptcha_public_key,
			use_ssl = False,
			error = error)
		return chtml