Example #1
0
 def get(self):
     gt = geetest.geetest(captcha_id, private_key)
     url = ""
     httpsurl = ""
     try:
         challenge = gt.geetest_register()
     except:
         challenge = ""
     if len(challenge) == 32:
         url = "http://%s%s&challenge=%s&product=%s" % (BASE_URL, captcha_id, challenge, product)
         httpsurl = "https://%s%s&challenge=%s&product=%s" % (BASE_URL, captcha_id, challenge, product)
     self.render("static/login.html", url=url)
Example #2
0
def home(request):
    gt = geetest.geetest(captcha_id, private_key)
    url = ""
    httpsurl = ""
    try:
        challenge = gt.geetest_register()
    except:
        challenge = ""
    if len(challenge) == 32:
        url = "http://%s%s&challenge=%s&product=%s" % (BASE_URL, captcha_id, challenge, product)
        httpsurl = "https://%s%s&challenge=%s&product=%s" % (BASE_URL, captcha_id, challenge, product)
    return render_to_response("index.html", {"url": url}, context_instance=RequestContext(request))
Example #3
0
 def get(self):
     gt = geetest.geetest(captcha_id, private_key)
     url = ""
     httpsurl = ""
     try:
         challenge = gt.geetest_register()
     except:
         challenge = ""
     if len(challenge) == 32:
         url = "http://%s%s&challenge=%s&product=%s" % (
             BASE_URL, captcha_id, challenge, product)
         httpsurl = "https://%s%s&challenge=%s&product=%s" % (
             BASE_URL, captcha_id, challenge, product)
     self.render("static/login.html", url=url)
Example #4
0
 def post(self):
     username = self.get_argument("email")
     password = self.get_argument("password")
     challenge = self.get_argument("geetest_challenge")
     validate = self.get_argument("geetest_validate")
     seccode = self.get_argument("geetest_seccode")
     # print challenge
     # print seccode
     # print validate
     gt = geetest.geetest(captcha_id, private_key)
     result = gt.geetest_validate(challenge, validate, seccode)
     if result:
         self.write("success")
     else:
         self.write("fail")
Example #5
0
 def post(self):
     username = self.get_argument("email")
     password = self.get_argument("password")
     challenge = self.get_argument("geetest_challenge")
     validate = self.get_argument("geetest_validate")
     seccode = self.get_argument("geetest_seccode")
     # print challenge
     # print seccode
     # print validate
     gt = geetest.geetest(captcha_id, private_key)
     result = gt.geetest_validate(challenge, validate, seccode)
     if result:
         self.write("success")
     else:
         self.write("fail")
Example #6
0
def login(request):
    if request.method == "POST":
        challenge = request.POST.get('geetest_challenge', '')
        validate = request.POST.get('geetest_validate', '')
        seccode = request.POST.get('geetest_seccode', '')
        # print challenge
        # print validate
        # print seccode
        gt = geetest.geetest(captcha_id, private_key)
        result = gt.geetest_validate(challenge, validate, seccode)
        if result:
            return HttpResponse("success")
        else:
            return HttpResponse("fail")
    else:
        return HttpResponse("e")
Example #7
0
def login():
    ua = request.user_agent
    if current_user.is_authenticated() and not is_wechat_device(ua):
        return redirect(url_for('groupview.list_groups'))
    if current_user.is_authenticated() and is_wechat_device(ua) and not current_user.is_binding_wechat():
        logout_user()
    form = LoginForm()
    error = None
    if request.method == 'POST' and form.validate_on_submit():
        login_user(form.user, remember=form.remember_me.data)
        param = {
            'ip': request.remote_addr,
            'agent': request.user_agent
        }
        form.user.logger(**param)
        openid = session.get('wechat_open_id', None)
        if openid:
            form.user.bind_wechat(openid)
            session.pop('wechat_open_id')
        return redirect(url_for('groupview.list_groups'))

    url = ''
    httpsurl = ''
    if current_app.config['CAPTCHA_ENABLE']:

        from sdk.geetest import geetest

        gt = geetest(current_app.config[
                     'CAPTCHA_KEY'], current_app.config['CAPTCHA_ID'])

        try:
            challenge = gt.geetest_register()
        except:
            challenge = ''
        if len(challenge) == 32:
            url, httpsurl = gt.geturl(challenge)

    rs = getBuildJSName()

    if is_wechat_device(ua) and is_mobile_user(ua):
        return render_template('./wechat/user/login.html', error=error, form=form, url=url, httpsurl=httpsurl, rs=rs)
    elif is_mobile_user(ua):
        return render_template('./wechat/user/login.html', error=error, form=form, url=url, httpsurl=httpsurl, rs=rs)
    return render_template('./wechat/user/login.html', error=error, form=form, url=url, httpsurl=httpsurl, rs=rs)