Skip to content

Commit

Permalink
fix: use current_app instead of 'app' for callbacks. (#176)
Browse files Browse the repository at this point in the history
Not sure this really mattered - but makes things uniform.
For @before_first_request callbacks - use current_app rather than app.
  • Loading branch information
jwag956 committed Sep 11, 2019
1 parent 1735ec5 commit a76b5b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions flask_security/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ def _register_i18n():
# N.B. as of jinja 2.9 '_' is always registered
# http://jinja.pocoo.org/docs/2.10/extensions/#i18n-extension
if "_" not in app.jinja_env.globals:
app.jinja_env.globals["_"] = state.i18n_domain.gettext
current_app.jinja_env.globals["_"] = state.i18n_domain.gettext

@app.before_first_request
def _csrf_init():
Expand Down Expand Up @@ -905,9 +905,9 @@ def _csrf_init():
if csrf:
csrf.exempt("flask_security.views.logout")
if csrf_cookie and csrf_cookie["key"]:
app.after_request(csrf_cookie_handler)
current_app.after_request(csrf_cookie_handler)
# Add configured header to WTF_CSRF_HEADERS
app.config["WTF_CSRF_HEADERS"].append(cv("CSRF_HEADER"))
current_app.config["WTF_CSRF_HEADERS"].append(cv("CSRF_HEADER"))

app.extensions["security"] = state

Expand Down

0 comments on commit a76b5b0

Please sign in to comment.