Exemplo n.º 1
0
    def post(self):
        username = self.request.get("username")
        password = self.request.get("password")
        user_query = db.GqlQuery("SELECT * FROM User WHERE username = '******'" %
                                 username)
        user = user_query.get()

        if user and hashutils.is_valid_pwd(username, password, user.pwd_hash):
            cookie_hash = hashutils.make_secure_val(user.key().id())
            self.response.headers.add_header('Set-Cookie',
                                             'user=%s; path=/' % cookie_hash)
            self.redirect('/')
        else:
            error = "Invalid credentials."
            self.render("login.html", error=error)
Exemplo n.º 2
0
 def set_secure_cookie(self, name, val):
     cookie_val = hashutils.make_secure_val(val)
     self.response.headers.add_header('Set-Cookie', '%s=%s; Path=/' % (name, cookie_val))
Exemplo n.º 3
0
 def set_secure_cookie(self, name, val):
     """ Adds a secure name-value pair cookie to the response """
     cookie_val = hashutils.make_secure_val(val)
     self.response.headers.add_header('Set-Cookie',
                                      '%s=%s; Path=/' % (name, cookie_val))
Exemplo n.º 4
0
 def set_secure_cookie(self, name, val):
     # takes the name of the cookie you want to set and the value of that cookie and sets it in the response headers.
     cookie_val = hashutils.make_secure_val(val)
     self.response.headers.add_header('Set-Cookie',
                                      '%s=%s; Path=/' % (name, cookie_val))