def load_user(email): user = None try: user = User.select([Equal("email", "'%s'" % email)], g.conn)[0] except BaseException as e: print e return user
def load_user(email): user = None try: user = User.select([Equal("email", "'%s'" % email)], []) user = user[0] if user else None except BaseException as e: flash("Login failed") print e return user
def login(): email = request.form["email"] password = request.form["password"] user = User.select([Equal("email", "'%s'" % email)], []) if (user and user[0].check_password(password)): user = user[0] user.authenticated = True login_user(user) else: flash(u'Invalid login information') return redirect("/")
def login(): # Here we use a class of some kind to represent and validate our # client-side form data. For example, WTForms is a library that will # handle this for us, and we use a custom LoginForm to validate. #form = LoginForm() print "login" if request.method == "POST": print "post" email = request.form["email"] password = request.form["password"] print email user = User.select([Equal("email", "'%s'" % email)], g.conn)[0] print user.password if (user and user.check_password(password)): print "correct login" login_user(user) else: flash('Username or password incorrect') return redirect("/")
def register(): email = request.form["email"] if not "@columbia.edu" in email and not "@barnard.edu" in email: flash(u'Invalid email address entered. Must use a valid CU or BU email') return redirect("/") try: uni = email.split("@")[0] first_name = request.form["first_name"] last_name = request.form["last_name"] raw_password = request.form["password"] except: flash("Invalid registration information. Ensure all fields are present.") return redirect("/") existing_user = User.select([Equal("email", "'%s'" % email)], []) if existing_user: flash("Account already created with that email..try logging in") return redirect("/") user = User(first_name, last_name, email, uni) user.set_password(raw_password) user.save() login_user(user) return redirect("/")