Has anyone used Flask-Security
extension for authentication? How do I get register view to work?
http://packages.python.org/Flask-Security/customizing.html
I am referring to link above.
@app.route('/register', methods=['GET'])
def register():
return render_template('security/register_user.html')
I don't want to extend the default class, I just want to wrap the default registration view in my site layout so I did this.
{% extends "layout.html" %}
{% block title %}upload{% endblock %}
{% block body %}
{% from "security/_macros.html" import render_field_with_errors, render_field %}
{% include "security/_messages.html" %}
<h1>Register</h1>
<form action="{{ url_for_security('register') }}" method="POST" name="register_user_form">
{{ register_user_form.hidden_tag() }}
{{ render_field_with_errors(register_user_form.email) }}
{{ render_field_with_errors(register_user_form.password) }}
{% if register_user_form.password_confirm %}
{{ render_field_with_errors(register_user_form.password_confirm) }}
{% endif %}
{{ render_field(register_user_form.submit) }}
</form>
{% include "security/_menu.html" %}
{% endblock %}
And I am getting the following error?
werkzeug.routing.BuildError
BuildError: ('security.register', {}, None)
You don't need to create the view. A default one is included in Flask-Security. You just need to enable it in your flask app config:
With this, the '/register' route should work.
There is another configuration value to change the URL if desired:
Other Flask-Security configuration information can be found here: http://pythonhosted.org/Flask-Security/configuration.html
I have not really used Flask-Security but the Builderror is referring to the fact that flask cannot bind the security.register view to a URL. security is the name of the blueprint. So may I suggest you try to call the view as follows. Instead of app.route, use security.route.