def home(): form = LoginForm(request.form) # Handle logging in if request.method == 'POST': if form.validate_on_submit(): login_user(form.user, remember=form.remember_me.data) flash("You are logged in.", 'success') redirect_url = request.args.get("next") or url_for("activities.overview") return redirect(redirect_url) else: flash_errors(form) return render_template("public/home.html", form=form)
def register(): register_form = RegisterForm(request.form, csrf_enabled=False) if register_form.validate_on_submit(): new_user = User.create(username=register_form.username.data, email=register_form.email.data, password=register_form.password.data, active=True) flash("Thank you for registering. You can now log in.", 'success') return redirect(url_for('public.home')) else: flash_errors(register_form) form = LoginForm() return render_template('public/register.html', register_form=register_form, form=form)