Exemple #1
0
def member_logout():
    set_cookie('customer_id', None)
    set_cookie('customer', None)
    set_cookie('customer_login_time', None)
    set_cookie('customer_login_ip', None)
    request.cookies.clear()
    redirect('login')
Exemple #2
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)

    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)
Exemple #3
0
def member_logout():
    set_cookie('customer_id',None)
    set_cookie('customer',None)
    set_cookie('customer_login_time', None)
    set_cookie('customer_login_ip', None)     
    request.cookies.clear()
    redirect('login')
Exemple #4
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)
    
    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)
Exemple #5
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)
Exemple #6
0
def portal_auth(db):
    user = request.params.get("user")
    token = request.params.get("token")
    secret = get_param_value(db, "8_portal_secret")
    date = utils.get_currdate()
    _token = md5("%s%s%s" % (user, secret, date)).hexdigest()
    if _token == token:
        account = get_account_by_number(db, user)
        print account
        if not account:
            return render("error", msg=u"用户%s不存在!" % user)
        member = db.query(models.SlcMember).get(account.member_id)
        set_cookie('customer_id', member.member_id, path="/")
        set_cookie('customer', member.member_name, path="/")
        set_cookie('customer_login_time', utils.get_currtime(), path="/")
        set_cookie('customer_login_ip', request.remote_addr, path="/")
        redirect("/")
    else:
        return render("error", msg=u"无效的访问!")
Exemple #7
0
def portal_auth(db):
    user = request.params.get("user")
    token = request.params.get("token")
    secret = get_param_value(db,"8_portal_secret")
    date = utils.get_currdate()
    _token = md5("%s%s%s"%(user,secret,date)).hexdigest()
    if _token == token:
        account = get_account_by_number(db,user)
        print account
        if not account:
            return render("error",msg=u"用户%s不存在!"%user)
        member = db.query(models.SlcMember).get(account.member_id)
        set_cookie('customer_id',member.member_id,path="/")
        set_cookie('customer',member.member_name,path="/")
        set_cookie('customer_login_time', utils.get_currtime(),path="/")
        set_cookie('customer_login_ip', request.remote_addr,path="/") 
        redirect("/")
    else:
        return render("error",msg=u"无效的访问!")