def register(): if current_user is not None and current_user.is_authenticated(): return redirect(url_for('chatChannels')) form = RegistrationForm() if form.validate_on_submit(): if form.password.data == form.passwordConfirmation.data: user = User(form.username.data, form.password.data) if UserManager.registerNewUser(session, user): return redirect(request.args.get("next") or url_for("login")) else: flash('This username is already in use') else: flash('Passwords do not match') return render_template("register.html", form=form)