def login(): """Logs the user in.""" if current_user is not None and current_user.is_authenticated: return redirect_or_next(url_for("forum.index")) current_limit = getattr(g, 'view_rate_limit', None) login_recaptcha = False if current_limit is not None: window_stats = limiter.limiter.get_window_stats(*current_limit) stats_diff = flaskbb_config["AUTH_REQUESTS"] - window_stats[1] login_recaptcha = stats_diff >= flaskbb_config["LOGIN_RECAPTCHA"] form = LoginForm(request.form) if form.validate_on_submit(): try: user = User.authenticate(form.login.data, form.password.data) if not login_user(user, remember=form.remember_me.data): flash( _("In order to use your account you have to activate it " "through the link we have sent to your email " "address."), "danger") return redirect_or_next(url_for("forum.index")) except AuthenticationError: flash(_("Wrong username or password."), "danger") return render_template("auth/login.html", form=form, login_recaptcha=login_recaptcha)
def login(): """Logs the user in.""" if current_user is not None and current_user.is_authenticated: return redirect_or_next(url_for("forum.index")) current_limit = getattr(g, 'view_rate_limit', None) login_recaptcha = False if current_limit is not None: window_stats = limiter.limiter.get_window_stats(*current_limit) stats_diff = flaskbb_config["AUTH_REQUESTS"] - window_stats[1] login_recaptcha = stats_diff >= flaskbb_config["LOGIN_RECAPTCHA"] form = LoginForm() if login_recaptcha and flaskbb_config["RECAPTCHA_ENABLED"]: form = LoginRecaptchaForm() if form.validate_on_submit(): try: user = User.authenticate(form.login.data, form.password.data) if not login_user(user, remember=form.remember_me.data): flash(_("In order to use your account you have to activate it " "through the link we have sent to your email " "address."), "danger") return redirect_or_next(url_for("forum.index")) except AuthenticationError: flash(_("Wrong username or password."), "danger") return render_template("auth/login.html", form=form, login_recaptcha=login_recaptcha)
def login(): """ Logs the user in """ if current_user is not None and current_user.is_authenticated(): return redirect(url_for("user.profile")) form = LoginForm(request.form) if form.validate_on_submit(): user, authenticated = User.authenticate(form.login.data, form.password.data) if user and authenticated: login_user(user, remember=form.remember_me.data) return redirect(request.args.get("next") or url_for("forum.index")) flash(("Wrong username or password"), "danger") return render_template("auth/login.html", form=form)
def login(): """ Logs the user in """ if current_user is not None and current_user.is_authenticated: return redirect(url_for("user.profile")) form = LoginForm(request.form) if form.validate_on_submit(): user, authenticated = User.authenticate(form.login.data, form.password.data) if user and authenticated: login_user(user, remember=form.remember_me.data) return redirect(request.args.get("next") or url_for("forum.index")) flash(_("Wrong Username or Password."), "danger") return render_template("auth/login.html", form=form)
def login(): """Logs the user in.""" if current_user is not None and current_user.is_authenticated: return redirect_or_next(url_for("forum.index")) current_limit = getattr(g, 'view_rate_limit', None) login_recaptcha = False if current_limit is not None: window_stats = limiter.limiter.get_window_stats(*current_limit) stats_diff = flaskbb_config["AUTH_REQUESTS"] - window_stats[1] login_recaptcha = stats_diff >= flaskbb_config["LOGIN_RECAPTCHA"] form = LoginForm(request.form) if form.validate_on_submit(): try: user = User.authenticate(form.login.data, form.password.data) login_user(user, remember=form.remember_me.data) return redirect_or_next(url_for("forum.index")) except AuthenticationError: flash(_("Wrong username or password."), "danger") return render_template("auth/login.html", form=form, login_recaptcha=login_recaptcha)
def form(self): if enforce_recaptcha(limiter): return LoginRecaptchaForm() return LoginForm()