コード例 #1
0
ファイル: customer.py プロジェクト: FoShanTK/ToughRADIUS
def member_login_post(db):
    next = request.params.get("next", "/")
    form = forms.member_login_form()
    if not form.validates(source=request.params):
        return render("login", form=form)
    
    if vcache.is_over(form.d.username,'0'):
        return render("error",msg=u"用户一小时内登录错误超过5次,请一小时后再试")

    member = db.query(models.SlcMember).filter_by(
        member_name=form.d.username
    ).first()
    
    if not member:
        return render("login", form=form,msg=u"用户不存在")
    
    if member.password != md5(form.d.password.encode()).hexdigest():
        vcache.incr(form.d.username,'0')
        print vcache.validates
        return render("login", form=form,msg=u"用户名密码错误第%s次"%vcache.errs(form.d.username,'0'))
 
    vcache.clear(form.d.username,'0')
 
    set_cookie('customer_id',member.member_id)
    set_cookie('customer',form.d.username)
    set_cookie('customer_login_time', utils.get_currtime())
    set_cookie('customer_login_ip', request.remote_addr) 
    redirect(next)
コード例 #2
0
ファイル: customer.py プロジェクト: SuPair/ToughRADIUS-1
def member_login_post(db):
    next = request.params.get("next", "/")
    form = forms.member_login_form()
    if not form.validates(source=request.params):
        return render("login", form=form)

    if vcache.is_over(form.d.username, '0'):
        return render("error", msg=u"用户一小时内登录错误超过5次,请一小时后再试")

    member = db.query(
        models.SlcMember).filter_by(member_name=form.d.username).first()

    if not member:
        return render("login", form=form, msg=u"用户不存在")

    if member.password != md5(form.d.password.encode()).hexdigest():
        vcache.incr(form.d.username, '0')
        print vcache.validates
        return render("login",
                      form=form,
                      msg=u"用户名密码错误第%s次" % vcache.errs(form.d.username, '0'))

    vcache.clear(form.d.username, '0')

    set_cookie('customer_id', member.member_id)
    set_cookie('customer', form.d.username)
    set_cookie('customer_login_time', utils.get_currtime())
    set_cookie('customer_login_ip', request.remote_addr)
    redirect(next)
コード例 #3
0
def member_login_post(db):
    next = request.params.get("next", "/")
    form = forms.member_login_form()
    if not form.validates(source=request.params):
        return render("login", form=form)

    member = db.query(models.SlcMember).filter_by(
        member_name=form.d.username,
        password=md5(form.d.password.encode()).hexdigest()).first()

    if not member:
        return render("login", form=form, msg=u"用户名密码不符合")

    set_cookie('customer_id', member.member_id)
    set_cookie('customer', form.d.username)
    set_cookie('customer_login_time', utils.get_currtime())
    set_cookie('customer_login_ip', request.remote_addr)
    redirect(next)
コード例 #4
0
def member_login_get(db):
    form = forms.member_login_form()
    form.next.set_value(request.params.get('next', '/'))
    return render("login", form=form)
コード例 #5
0
ファイル: customer.py プロジェクト: FoShanTK/ToughRADIUS
def member_login_get(db):
    form = forms.member_login_form()
    form.next.set_value(request.params.get('next','/'))
    return render("login",form=form)