def chn_pw(uid): opassword = request.forms.getunicode('opassword') npassword = request.forms.getunicode('npassword') kpassword = request.forms.getunicode('kpassword') name = request.get_cookie('name',secret=secret) if npassword and npassword == kpassword: user.ch_pw(uid,name,opassword,npassword) redirect('/logout') else: response.set_cookie('info','可能是密码不匹配或为空!',secret=secret) redirect('/me/%s' % uid)
def chgpw(uid): id = login_verify() if uid != id: redirect('/admin') if request.method == "GET": name = request.get_cookie('name',secret=secret) user_type = request.get_cookie('user_type',secret=secret) id = request.get_cookie('id',secret=secret) return template('tpls/chgpw.tpl', name=name, id=id, user_type=user_type) elif request.method == "POST": opassword = request.forms.getunicode('opassword').strip() npassword = request.forms.getunicode('npassword').strip() kpassword = request.forms.getunicode('kpassword').strip() name = request.get_cookie('name',secret=secret) if opassword and npassword and\ npassword == kpassword and opassword != npassword: user.ch_pw(uid,opassword,npassword,name) response.set_cookie('info','你密码更改,请重新登录!',secret=secret) redirect('/logout')