Exemple #1
0
 def POST(self):
     if not self.form.validates():
         return render.signup(self.form, '注册失败,请重注', self.crumb.output())
     try:
         condition = {'name': self.form.d.name}
         user = user_model().get_one(condition)
         # 对密码进行 md5 加密
         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(' ', '')
         password = hashlib.md5(
             hashlib.md5(self.form.d.password).hexdigest() +
             auth).hexdigest()
         #password = hashlib.md5(self.form.d.password).hexdigest()
         if user is not None:
             raise ValueExistsError('用户名已经存在')
         condition = {'email': self.form.d.email}
         user = user_model().get_one(condition)
         if user is not None:
             raise ValueExistsError('邮箱已经存在')
         user_model().insert({
             'name': self.form.d.name,
             'email': self.form.d.email,
             'password': password,
             'regist_time': time.time(),
             'auth': auth
         })
     except ValueExistsError, x:
         return render.signup(self.form, x.message, self.crumb.output())
Exemple #2
0
 def POST(self):
     if not self.form.validates():
         return render.signup(self.form, '注册失败,请重注', self.crumb.output())
     try:
         condition = {'name':self.form.d.name}
         user = user_model().get_one(condition)
         # 对密码进行 md5 加密
         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(' ','')
         password = hashlib.md5(hashlib.md5(self.form.d.password).hexdigest() + auth).hexdigest()
         #password = hashlib.md5(self.form.d.password).hexdigest()
         if user is not None:
             raise ValueExistsError('用户名已经存在')
         condition = {'email' : self.form.d.email}
         user = user_model().get_one(condition)
         if user is not None:
             raise ValueExistsError('邮箱已经存在')
         user_model().insert({'name' : self.form.d.name, 'email' : self.form.d.email, 'password' : password, 'regist_time' : time.time(), 'auth' : auth})
     except ValueExistsError, x:
         return render.signup(self.form, x.message, self.crumb.output())
Exemple #3
0
 def POST(self):
     ret, msg = self._post()
     if ret:
         return render.signup(self.form, msg, self.crumb.output())
     else:
         raise web.SeeOther('/')
Exemple #4
0
 def GET(self):
     title = '注册'
     return render.signup(self.form, title, self.crumb.output())