zoukankan      html  css  js  c++  java
  • flask-login

    1.配置
    login_manager = LoginManager()
    login_manager.init_app(app)

    例子:
    @app.route('/login', methods=['GET', 'POST'])
    def login():
    # Here we use a class of some kind to represent and validate our
    # client-side form data. For example, WTForms is a library that will
    # handle this for us, and we use a custom LoginForm to validate.
    form = LoginForm()
    if form.validate_on_submit():
    # Login and validate the user.
    # user should be an instance of your User class
    login_user(user)

        flask.flash('Logged in successfully.')
    
        next = flask.request.args.get('next')
        # next_is_valid should check if the user has valid
        # permission to access the `next` url
        if not next_is_valid(next):
            return flask.abort(400)
    
        return flask.redirect(next or flask.url_for('index'))
    return flask.render_template('login.html', form=form)
    

    警告: 你必须验证 next 参数的值。如果不验证的话,你的应用将会受到重定向的攻击。

    秋来凉风起,无限思远人
  • 相关阅读:
    1 let和const
    ECMAScript 6 扫盲
    回溯法
    13. Ajax技术
    12.JSTL标签
    11.EL(表达式语言)
    10.正则表达式(未完成)
    博客园自定义样式
    9.一次简单的Web作业
    8.JavaScript
  • 原文地址:https://www.cnblogs.com/lalavender/p/10436598.html
Copyright © 2011-2022 走看看