Ejemplo n.º 1
0
    def post(self):
        user_username = self.request.get('username')
        user_password = self.request.get('password')
        user_verify = self.request.get('verify')
        user_email = self.request.get('email')

        errors = common.check_signup(user_username, user_password, user_verify,
                                     user_email)
        if errors:
            self.render("Registration.html",
                        error=errors[0],
                        error2=errors[1],
                        error3=errors[2],
                        error4=errors[3],
                        username=user_username)
        else:
            u = entities.User(
                username=user_username,
                password=common.make_pw_hash(user_username, user_password),
                email=user_email
            )  #the password is made up of a combination of username, password and a secret value
            u.put()
            user_id = u.key().id()
            new_cookie_val = common.make_secure_val(
                str(user_id)
            )  #passes the user id into this function to get a hash of the user id
            self.response.headers.add_header(
                'Set-Cookie', 'user_id=%s; Path=/' % new_cookie_val)
            self.redirect("/blog/welcome")
Ejemplo n.º 2
0
	def post(self):
		user_username = self.request.get('username')
		user_password = self.request.get('password')
		user_verify = self.request.get('verify')
		user_email = self.request.get('email')
		
		errors = common.check_signup(user_username, user_password, user_verify, user_email)
		if errors:
			self.render("Registration.html",error = errors[0],error2 = errors[1],error3 = errors[2],error4 = errors[3],username = user_username)
		else:
			u = entities.User(username = user_username, password = common.make_pw_hash(user_username,user_password), email = user_email) #the password is made up of a combination of username, password and a secret value
			u.put()
			user_id = u.key().id()
			new_cookie_val = common.make_secure_val(str(user_id))#passes the user id into this function to get a hash of the user id
			self.response.headers.add_header('Set-Cookie', 'user_id=%s; Path=/' % new_cookie_val)
			self.redirect("/blog/welcome")
Ejemplo n.º 3
0
	def post(self):
		user_username = self.request.get('username')
		user_password = self.request.get('password')
		err1 = ""
		users = db.GqlQuery("SELECT * FROM User")
		user_exist = None
		for user in users:
			if common.valid_pw(user_username,user_password,user.password):
				user_exist = user
		if user_exist:
			user_id = user_exist.key().id()
			new_cookie_val = common.make_secure_val(str(user_id))
			self.response.headers.add_header('Set-Cookie', 'user_id=%s; Path=/' % new_cookie_val)
			self.redirect("/blog/welcome")
		else:
			err1 = "Invalid login"
			self.render("login.html",error = err1)
Ejemplo n.º 4
0
 def post(self):
     user_username = self.request.get('username')
     user_password = self.request.get('password')
     err1 = ""
     users = db.GqlQuery("SELECT * FROM User")
     user_exist = None
     for user in users:
         if common.valid_pw(user_username, user_password, user.password):
             user_exist = user
     if user_exist:
         user_id = user_exist.key().id()
         new_cookie_val = common.make_secure_val(str(user_id))
         self.response.headers.add_header(
             'Set-Cookie', 'user_id=%s; Path=/' % new_cookie_val)
         self.redirect("/blog/welcome")
     else:
         err1 = "Invalid login"
         self.render("login.html", error=err1)