当前位置: 首页>>代码示例>>Python>>正文


Python User.authenticate方法代码示例

本文整理汇总了Python中flaskbb.user.models.User.authenticate方法的典型用法代码示例。如果您正苦于以下问题:Python User.authenticate方法的具体用法?Python User.authenticate怎么用?Python User.authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flaskbb.user.models.User的用法示例。


在下文中一共展示了User.authenticate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: login

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import authenticate [as 别名]
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)
开发者ID:djsilcock,项目名称:flaskbb,代码行数:31,代码来源:views.py

示例2: login

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import authenticate [as 别名]
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)
开发者ID:hvdklauw,项目名称:flaskbb,代码行数:20,代码来源:views.py

示例3: login

# 需要导入模块: from flaskbb.user.models import User [as 别名]
# 或者: from flaskbb.user.models.User import authenticate [as 别名]
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)
开发者ID:AnantharamanG2,项目名称:flaskbb,代码行数:25,代码来源:views.py


注:本文中的flaskbb.user.models.User.authenticate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。