def regist_validate(): print("Got Post Info") print(request.form) data = { "first_name": request.form["first_name"], "last_name": request.form["last_name"], "username": request.form["username"], "email": request.form["email"], "password": request.form["password"], "confirm_password": request.form["confirm_password"] } account = Account.get_account_by_username(data) if len(account) > 0: flash( "Username has been used for registration already, please choose a unique one." ) return redirect('/regist') if not Account.validate_regist(data): return redirect("/regist") pw_hash = bcrypt.generate_password_hash(data["password"]) data["password"] = pw_hash new_account_id = Account.insert_one(data) print(new_account_id) session["user_id"] = new_account_id session["username"] = data["username"] return redirect("/dashboard")
def regist_validate(): print("Got Post Info") print(request.form) data = { "first_name": request.form["first_name"], "last_name": request.form["last_name"], "email": request.form["email"], "password": request.form["password"], "confirm_password": request.form["confirm_password"] } account = Account.get_account_by_email(data) if len(account) > 0: flash("Email has been used for registration already.", 'email') return redirect('/') if not Account.validate_regist(account, data): return redirect("/") pw_hash = bcrypt.generate_password_hash(data["password"]) data["password"] = pw_hash new_account_id = Account.insert_one(data) print(new_account_id) session["user_id"] = new_account_id session["first_name"] = data["first_name"] return redirect("/login")