def register(): print("starting register") email = request.form["email"] first_name = request.form["first_name"] last_name = request.form["last_name"] raw_password = request.form["password"] user = User(first_name, last_name, email) print("created user") user.set_password(raw_password) user.save(g.conn) print("Saving user") 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("/")