예제 #1
0
 def post(self):
     user_username = self.request.get('username')
     user_password = self.request.get('password')
     params = dict(username = user_username)
     query = User.all().filter('username', user_username)
     user = query.get()
     if user:
         check_user = auth_helpers.valid_pw(user_username, user_password, user.encrypted_pass)
         if check_user:
             #set cookie and redirect to welcome page
             user_id = user.key().id()
             user_hash = auth_helpers.make_secure_val(str(user_id))
             self.response.headers.add_header("Set-Cookie", "user = %s" % str(user_hash))
             self.redirect("/unit3/welcome")
         else:
             params["error_username"] = "******"
             params["error_password"] = "******"
             self.render("login.html", **params)
     else:
         params["error_username"] = "******"
         params["error_password"] = "******"
         self.render("login.html", **params)
예제 #2
0
파일: main.py 프로젝트: rlofblad/cs253-wiki
 def login(cls, name, pw):
     u = cls.by_name(name)
     if u and auth_helpers.valid_pw(name, pw, u.pw_hash):
         return u
예제 #3
0
 def login(cls, name, pw):
     u = cls.by_name(name)
     if u and auth_helpers.valid_pw(name, pw, u.pw_hash):
         return u