Ejemplo n.º 1
0
 def post(self):
     username = self.request.get('username')
     password = self.request.get('password')
     verify = self.request.get('verify')
     email = self.request.get('email')
     error1 = ""
     error2 = ""
     error3 = ""
     error4 = ""
     error5 = ""
     if not valid_username(username):
     	error1 = "This is not a valid user name"
     if not valid_password(password):
     	error2 = "This is not a valid password"
     if password != verify:
     	error3 = "Your password doesn't match"
     if email != "" and not valid_email(email):
     	error4 = "This is not a valid email"
     if db.GqlQuery("SELECT * FROM User where username ='******'"%username).fetch(1):
     	error5 = "User already exists"
     if error1 == "" and error2 == "" and error3 == "" and error4 == "" and error5 == "":
     	encrypt = passwordencrypt.make_pw_hash(username, password)
     	logging.error( "u=%s p=%s s=%s" %(username, encrypt[0], encrypt[1]))
    	u = User(username=username, password=encrypt[0], salt=encrypt[1])
    	u.put()
    	userid = u.key().id()
    	cookie_val = passwordencrypt.make_cookie(str(userid))
    	self.response.headers.add_header('Set-Cookie', '%s=%s; Path=/'%(USERID_COOKIE, cookie_val))
     	self.redirect("/wiki")
     else:
     	logging.error("writng error form " + error1+ " " + error2+ " " + error5)
     	self.write_form(error1, error2, error3, error4, error5, username, email)      
Ejemplo n.º 2
0
 def post(self):
     username = self.request.get('username')
     password = self.request.get('password')
     verify = self.request.get('verify')
     email = self.request.get('email')
     error1 = ""
     error2 = ""
     error3 = ""
     error4 = ""
     if not valid_username(username):
     	error1 = "This is not a valid user name"
     if not valid_password(password):
     	error2 = "This is not a valid password"
     if password != verify:
     	error3 = "Your password doesn't match"
     if email != "" and not valid_email(email):
     	error4 = "This is not a valid email"
     if error1 == "" and error2 == "" and error3 == "" and error4 == "":
     	encrypt = passwordencrypt.make_pw_hash(username, password)
     	#print "u=%s p=%s s=%s" %(username, encrypt[0], encrypt[1])
    	u = User(username=username, password=encrypt[0], salt=encrypt[1])
    	u.put()
    	userid = u.key().id()
    	cookie_val = passwordencrypt.make_cookie(userid,encrypt[0])
    	self.response.headers.add_header('Set-Cookie', '%s=%s; Path=/'%(USERID_COOKIE, cookie_val))
     	self.redirect("/blog/welcome")
     else:
     	self.write_form(error1, error2, error3, error4, username, email)