def post(self): username = self.request.get('username') password = self.request.get('password') #query for user data q = Users.all() q.filter("username ="******"Invalid login.", username = username, not_relevant = True)
def post(self): username = self.request.get('username') password = self.request.get('password') #query for user data q = Users.all() q.filter("username ="******"Invalid login.", username=username, not_relevant=True)
def post(self): username = self.request.get('username') password = self.request.get('password') verify = self.request.get('verify') email = self.request.get('email') valid_username = validate_username(username) valid_password = validate_password(password) and validate_password(verify) mismatch_passwords = password == verify valid_email = validate_email(email) #query for user data to check for duplicate users in db q = Users.all() q.filter("username ="******"That's not a valid username." if not valid_password: error_password = "******" elif not mismatch_passwords: error_mismatch_passwords = "Your passwords didn't match." if (not valid_email) and email != '': error_email = "That's not a valid email." self.render('signup.html', error_username = error_username, error_password = error_password, error_mismatch_passwords = error_mismatch_passwords, error_email = error_email, username = username, email = email) else: #hash password hashed_password = make_pw_hash(username, password) if email: recently_added_user = Users(username = username, password = hashed_password, email = email) else: recently_added_user = Users(username = username, password = hashed_password, email = '*****@*****.**') recently_added_user.put() #make cookie hash user_id = str(recently_added_user.key().id()) cookie_data = make_user_cookie_hash(user_id, username) self.response.headers.add_header('Set-Cookie', 'user_id=%s; Path=/blog' % cookie_data) self.redirect('/blog/welcome')
def post(self): username = self.request.get('username') password = self.request.get('password') verify = self.request.get('verify') email = self.request.get('email') valid_username = validate_username(username) valid_password = validate_password(password) and validate_password( verify) mismatch_passwords = password == verify valid_email = validate_email(email) #query for user data to check for duplicate users in db q = Users.all() q.filter("username ="******"That's not a valid username." if not valid_password: error_password = "******" elif not mismatch_passwords: error_mismatch_passwords = "Your passwords didn't match." if (not valid_email) and email != '': error_email = "That's not a valid email." self.render('signup.html', error_username=error_username, error_password=error_password, error_mismatch_passwords=error_mismatch_passwords, error_email=error_email, username=username, email=email) else: #hash password hashed_password = make_pw_hash(username, password) if email: recently_added_user = Users(username=username, password=hashed_password, email=email) else: recently_added_user = Users(username=username, password=hashed_password, email='*****@*****.**') recently_added_user.put() #make cookie hash user_id = str(recently_added_user.key().id()) cookie_data = make_user_cookie_hash(user_id, username) self.response.headers.add_header( 'Set-Cookie', 'user_id=%s; Path=/blog' % cookie_data) self.redirect('/blog/welcome')