def login(): if current_user.is_authenticated(): return redirect(url_for('index')) form = LoginForm() if form.validate_on_submit(): user = Advertiser.objects(email=form.email.data).first() print(user.password) print(form.password.data) if user.password != form.password.data: return render_template('login.html', form=form, error="Wrong username or password") else: login_user(user) return redirect(url_for('index')) return render_template('login.html', form=form)
def load_user(user_id): return Advertiser.objects(id=user_id).first()