File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 1
1
import functools
2
2
3
- from flask import session
3
+ from flask import request , session
4
4
from flask_login import current_user
5
5
from flask_talisman import talisman
6
6
from flask_wtf .csrf import CSRFProtect , generate_csrf
@@ -35,6 +35,15 @@ def inject_csrf_token(response):
35
35
36
36
@app .before_request
37
37
def check_csrf ():
38
+ # BEGIN workaround until https://github.com/lepture/flask-wtf/pull/419 is merged
39
+ if request .blueprint in csrf ._exempt_blueprints :
40
+ return
41
+
42
+ view = app .view_functions .get (request .endpoint )
43
+ if view is not None and f"{ view .__module__ } .{ view .__name__ } " in csrf ._exempt_views :
44
+ return
45
+ # END workaround
46
+
38
47
if not current_user .is_authenticated or "user_id" in session :
39
48
csrf .protect ()
40
49
You can’t perform that action at this time.
0 commit comments