Пример #1
0
def reset_password():
    form = ResetPasswordForm()
    token = request.args.get("token")
    if not token:
        return render_template("reset_password.html",
                               form=form,
                               error=_("No token provided"))
    project_id = Project.verify_token(token)
    if not project_id:
        return render_template("reset_password.html",
                               form=form,
                               error=_("Invalid token"))
    project = Project.query.get(project_id)
    if not project:
        return render_template("reset_password.html",
                               form=form,
                               error=_("Unknown project"))

    if request.method == "POST" and form.validate():
        project.password = generate_password_hash(form.password.data)
        db.session.add(project)
        db.session.commit()
        flash(_("Password successfully reset."))
        return redirect(url_for(".home"))
    return render_template("reset_password.html", form=form)
Пример #2
0
def reset_password():
    form = ResetPasswordForm()
    token = request.args.get('token')
    if not token:
        return render_template('reset_password.html', form=form, error=_("No token provided"))
    project_id = Project.verify_token(token)
    if not project_id:
        return render_template('reset_password.html', form=form, error=_("Invalid token"))
    project = Project.query.get(project_id)
    if not project:
        return render_template('reset_password.html', form=form, error=_("Unknown project"))

    if request.method == "POST" and form.validate():
        project.password = generate_password_hash(form.password.data)
        db.session.add(project)
        db.session.commit()
        flash(_("Password successfully reset."))
        return redirect(url_for(".home"))
    return render_template('reset_password.html', form=form)