def post(self): username = self.request.get('username') password = self.request.get('password') params= dict(username = username) if valid_user(username): u= memcache_user(username = username) if u and check_pw(username, password, u.password_hash): self.set_secure_cookie('uid',str(u.key().id())) # if not 'login' in referer: # self.redirect(referer) # else: self.redirect("/") else: self.render("login.html", user_auth = user_auth, login_error = "Invalid login")
def post(self): referer = self.request.referer has_error = False username = self.request.get("username") password = self.request.get("password") password_verify = self.request.get("verify") email = self.request.get("email") params=dict(username=username, email=email) if not valid_user(username): params['error_username'] = "******" has_error = True if not valid_password(password): params['error_password'] = "******" has_error =True if password_verify != password: params['error_verify'] = "Your passwords do not match." has_error =True if not valid_email(email): params['error_email'] = "Something seems to be wrong. Check your email address." has_error = True if has_error == True: self.render("signup.html", **params) else: if memcache_user(username = username) == None: u = USERS.register(username,password,email) u.put() memcache_user(update = True) self.set_secure_cookie('uid',str(u.key().id())) self.redirect("/") else: params['error_username'] = "******" self.render("signup.html", **params)