def post(self): user_username = self.request.get('username') user_password = self.request.get('password') user_verify = self.request.get('verify') user_email = self.request.get('email') user_name = escape_html(user_username) user_pass = escape_html(user_password) pass_verify = escape_html(user_verify) email_id = escape_html(user_email) username_error = "" password_error = "" verify_error = "" email_error = "" error = False temp = User.all().filter('username ='******'kjbjlj' username_error = "That's not a valid Username!" error = True if not valid_password(user_password): password_error = "That's not a valid password!" error = True if not user_verify or not user_password == user_verify: verify_error = "Passwords do not match" error = True if not valid_email(user_email): email_error = "That's not a valid email!" error = True if error: self.render("signup.html", username=user_name, email=email_id, username_error=username_error, password_error=password_error, verify_error=verify_error, email_error=email_error) else: if not user_email or valid_email(user_email): b = User(username=user_username, password=user_password, email=user_email) b.put() self.set_secure_cookie("user_name", str(user_name)) self.redirect("/")
def post(self): user_valid = self.request.get("username") pass_valid = self.request.get("password") valid_login = User.all().filter("username ="******"" if valid_login and user_valid == valid_login.username and pass_valid == valid_login.password: self.set_secure_cookie("user_name", str(user_valid)) self.redirect("/") else: error = "That's not a valid Login" self.render("login.html", error=error, valid_login=valid_login)
def createUser(self, content): print(content) try: user = User(content["name"], content["email"], DB.encrypt(content["pin"])) except KeyError as e: raise BadRequest("I/O error: {0} was not included".format(e)) try: user.clockwidget = content["clockwidget"] except KeyError as e: print("I/O error: {0} was not included".format(e)) try: user.home = content["homeAddress"] except KeyError as e: print("I/O error: {0} was not included".format(e)) try: user.work = content["workAddress"] except KeyError as e: print("I/O error: {0} was not included".format(e)) try: user.twitterwidget = content["twitterwidget"] except KeyError as e: print("I/O error: {0} was not included".format(e)) try: user.calendarwidget = content["calendarwidget"] except KeyError as e: print("I/O error: {0} was not included".format(e)) try: user.mapswidget = content["mapswidget"] except KeyError as e: print("I/O error: {0} was not included".format(e)) try: user.weatherwidget = content["weatherwidget"] except KeyError as e: print("I/O error: {0} was not included".format(e)) return user
def valid_user(content): user = User.all().filter('content=', content) return user
google = oauth.remote_app( 'google', consumer_key=os.environ.get('GOOGLE_ID'), consumer_secret=os.environ.get('GOOGLE_SECRET'), request_token_params={ 'scope': 'https://www.googleapis.com/auth/calendar.readonly email profile https://www.googleapis.com/auth/gmail.readonly' }, base_url='https://www.googleapis.com/oauth2/v1/', request_token_url=None, access_token_method='POST', access_token_url='https://accounts.google.com/o/oauth2/token', authorize_url='https://accounts.google.com/o/oauth2/auth', ) currentUser = User("", "", "") @app.route('/') def index(): return render_template('index.html') @app.route('/login') def login(): return google.authorize(callback=url_for('authorized', _external=True), prompt='consent') @app.route('/logout') def logout():