Search code examples
pythonflaskflask-security

How to customize registration provided by Flask-security?


What am i supposed to do, if need to set up Role of user to, for example FooUser? Where i need to do this? In my own /create_account view or in context processor?

@app.route('/create_account')
def create_account():
    user_datastore.find_or_create_role('FooUser')
    user_datastore.add_role_to_user(user,role)
    return render_template('register_user.html')

Solution

  • You may customize views following these instructions: http://flask-security.readthedocs.org/en/latest/customizing.html

    And you may hook into the user registration process using signals: http://flask-security.readthedocs.org/en/latest/api.html#signals