def login(): next = request.args.get('next') form = LoginForm() if form.validate_on_submit(): user = User(mongo, form.data['username'], password=form.data['password']) if not user.is_authenticated(): flash('Brugernavn eller password forkert') return render_template('login.html', form=form, next=next) #return redirect('/login') else: res = login_user(user) return redirect('/') return render_template("login.html", form=form)
def load_user(username): user = User(mongo, username) if user.is_authenticated(): return user return None