def post(self): if not self.validate(self.request): self.render_form() else: user = User(name=self.username, password_hash=Hash.password(self.username, self.password), email=(self.email if self.email else None )) user.put() self.set_cookie('userid', user.key()) self.redirect('/blog/home')
def find_by_username_and_password(username, password): users = User.gql("where name = '%s'" % username) for user in users: if Hash.verify_password(user.name, password, user.password_hash): return user