Update default login template and add security state to app context processory

This commit is contained in:
Matt Wright
2012-08-16 18:03:47 -04:00
parent 8b139890b4
commit eeace79ef9
4 changed files with 14 additions and 15 deletions
-11
View File
@@ -1,11 +0,0 @@
{% include "_messages.html" %}
{% include "_nav.html" %}
<form action="{{ url_for_security('authenticate') }}" method="POST" name="login_form">
{{ form.hidden_tag() }}
{{ form.email.label }} {{ form.email }}<br/>
{{ form.password.label }} {{ form.password }}<br/>
{{ form.remember.label }} {{ form.remember }}<br/>
{{ form.next }}
{{ form.submit }}
</form>
<p>{{ content }}</p>
+3 -2
View File
@@ -256,12 +256,13 @@ class Security(object):
template_folder='templates')
app.register_blueprint(bp)
app.context_processor(lambda: dict(url_for_security=url_for_security))
state = self._get_state(app, datastore or self.datastore)
app.extensions['security'] = state
app.context_processor(lambda: dict(url_for_security=url_for_security,
security=state))
return state
def _get_state(self, app, datastore):
@@ -1,6 +1,6 @@
{% from "security/_macros.html" import render_field_with_errors, render_field %}
{% include "security/_messages.html" %}
<h1>Send reset password instructions</h1>
<h1>Send password reset instructions</h1>
<form action="{{ url_for_security('forgot_password') }}" method="POST" name="forgot_password_form">
{{ forgot_password_form.hidden_tag() }}
{{ render_field_with_errors(forgot_password_form.email) }}
+10 -1
View File
@@ -8,4 +8,13 @@
{{ render_field_with_errors(login_form.remember) }}
{{ render_field(login_form.next) }}
{{ render_field(login_form.submit) }}
</form>
</form>
<h2>Help</h2>
<p>
{% if security.recoverable %}
<a href="{{ url_for_security('forgot_password') }}">Forgot password</a><br/>
{% endif %}
{% if security.confirmabled %}
<a href="{{ url_for_security('send_confirmation') }}">Confirm account</a>
{% endif %}
</p>