mirror of
https://github.com/wassname/flask-security.git
synced 2026-06-27 16:10:11 +08:00
Allow overwritten on render_template to use Flask-Themes based app
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
:license: MIT, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
from flask import current_app
|
||||
from flask import current_app, render_template
|
||||
from flask.ext.login import AnonymousUserMixin, UserMixin as BaseUserMixin, \
|
||||
LoginManager, current_user
|
||||
from flask.ext.principal import Principal, RoleNeed, UserNeed, Identity, \
|
||||
@@ -382,9 +382,13 @@ class Security(object):
|
||||
app.register_blueprint(create_blueprint(state, __name__))
|
||||
app.context_processor(_context_processor)
|
||||
|
||||
state.render_template = self.render_template
|
||||
app.extensions['security'] = state
|
||||
|
||||
return state
|
||||
|
||||
def render_template(self, *args, **kwargs):
|
||||
return render_template(*args, **kwargs)
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(self._state, name, None)
|
||||
|
||||
+23
-23
@@ -9,7 +9,7 @@
|
||||
:license: MIT, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
from flask import current_app, redirect, request, render_template, jsonify, \
|
||||
from flask import current_app, redirect, request, jsonify, \
|
||||
after_this_request, Blueprint
|
||||
from flask_login import current_user
|
||||
from werkzeug.datastructures import MultiDict
|
||||
@@ -83,9 +83,9 @@ def login():
|
||||
if request.json:
|
||||
return _render_json(form, True)
|
||||
|
||||
return render_template(config_value('LOGIN_USER_TEMPLATE'),
|
||||
login_user_form=form,
|
||||
**_ctx('login'))
|
||||
return _security.render_template(config_value('LOGIN_USER_TEMPLATE'),
|
||||
login_user_form=form,
|
||||
**_ctx('login'))
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -127,9 +127,9 @@ def register():
|
||||
if request.json:
|
||||
return _render_json(form)
|
||||
|
||||
return render_template(config_value('REGISTER_USER_TEMPLATE'),
|
||||
register_user_form=form,
|
||||
**_ctx('register'))
|
||||
return _security.render_template(config_value('REGISTER_USER_TEMPLATE'),
|
||||
register_user_form=form,
|
||||
**_ctx('register'))
|
||||
|
||||
|
||||
def send_login():
|
||||
@@ -150,9 +150,9 @@ def send_login():
|
||||
if request.json:
|
||||
return _render_json(form)
|
||||
|
||||
return render_template(config_value('SEND_LOGIN_TEMPLATE'),
|
||||
send_login_form=form,
|
||||
**_ctx('send_login'))
|
||||
return _security.render_template(config_value('SEND_LOGIN_TEMPLATE'),
|
||||
send_login_form=form,
|
||||
**_ctx('send_login'))
|
||||
|
||||
|
||||
@anonymous_user_required
|
||||
@@ -195,9 +195,9 @@ def send_confirmation():
|
||||
if request.json:
|
||||
return _render_json(form)
|
||||
|
||||
return render_template(config_value('SEND_CONFIRMATION_TEMPLATE'),
|
||||
send_confirmation_form=form,
|
||||
**_ctx('send_confirmation'))
|
||||
return _security.render_template(config_value('SEND_CONFIRMATION_TEMPLATE'),
|
||||
send_confirmation_form=form,
|
||||
**_ctx('send_confirmation'))
|
||||
|
||||
|
||||
def confirm_email(token):
|
||||
@@ -246,9 +246,9 @@ def forgot_password():
|
||||
if request.json:
|
||||
return _render_json(form)
|
||||
|
||||
return render_template(config_value('FORGOT_PASSWORD_TEMPLATE'),
|
||||
forgot_password_form=form,
|
||||
**_ctx('forgot_password'))
|
||||
return _security.render_template(config_value('FORGOT_PASSWORD_TEMPLATE'),
|
||||
forgot_password_form=form,
|
||||
**_ctx('forgot_password'))
|
||||
|
||||
|
||||
@anonymous_user_required
|
||||
@@ -275,10 +275,10 @@ def reset_password(token):
|
||||
return redirect(get_url(_security.post_reset_view) or
|
||||
get_url(_security.post_login_view))
|
||||
|
||||
return render_template(config_value('RESET_PASSWORD_TEMPLATE'),
|
||||
reset_password_form=form,
|
||||
reset_password_token=token,
|
||||
**_ctx('reset_password'))
|
||||
return _security.render_template(config_value('RESET_PASSWORD_TEMPLATE'),
|
||||
reset_password_form=form,
|
||||
reset_password_token=token,
|
||||
**_ctx('reset_password'))
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -303,9 +303,9 @@ def change_password():
|
||||
if request.json:
|
||||
return _render_json(form)
|
||||
|
||||
return render_template('security/change_password.html',
|
||||
change_password_form=form,
|
||||
**_ctx('change_password'))
|
||||
return _security.render_template('security/change_password.html',
|
||||
change_password_form=form,
|
||||
**_ctx('change_password'))
|
||||
|
||||
|
||||
def create_blueprint(state, import_name):
|
||||
|
||||
Reference in New Issue
Block a user