예제 #1
0
파일: user.py 프로젝트: zhjchina/post_bar
 def POST(self):
     self.crumb.append('设置', '/settings')
     self.crumb.append('修改密码')
     user = user_model().get_one({'id': session.user_id})
     if self.form.validates():
         password = hashlib.md5(
             hashlib.md5(self.form.d.origin_password).hexdigest() +
             user.auth).hexdigest()
         if user.password == password:
             auth = string.join(
                 random.sample([
                     'z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p',
                     'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e',
                     'd', 'c', 'b', 'a'
                 ], 5)).replace(' ', '')
             new_password = hashlib.md5(
                 hashlib.md5(self.form.d.new_password).hexdigest() +
                 auth).hexdigest()
             user_model().update({'id': user.id}, {
                 'password': new_password,
                 'auth': auth
             })
             raise web.SeeOther('/settings')
         else:
             return render.password('原密码不正确', self.crumb.output(),
                                    self.form)
     else:
         return render.password('修改密码', self.crumb.output(), self.form)
예제 #2
0
파일: user.py 프로젝트: codepongo/post_bar
 def POST(self):
     self.crumb.append('设置', '/settings')
     self.crumb.append('修改密码')
     user = user_model().get_one({'id':session.user_id})
     if self.form.validates():
         password = hashlib.md5(hashlib.md5(self.form.d.origin_password).hexdigest() + user.auth).hexdigest()
         if user.password == password:
             auth = string.join(random.sample(['z','y','x','w','v','u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a'], 5)).replace(' ','')
             new_password = hashlib.md5(hashlib.md5(self.form.d.new_password).hexdigest() + auth).hexdigest()
             user_model().update({'id':user.id}, {'password':new_password, 'auth':auth})
             raise web.SeeOther('/settings')
         else:
             return render.password('原密码不正确', self.crumb.output(), self.form)
     else:
         return render.password('修改密码', self.crumb.output(), self.form)
예제 #3
0
 def GET(self):
     self.crumb.append('设置', '/settings')
     self.crumb.append('修改密码')
     return render.password('修改密码', self.crumb.output(), self.form)