Skip to content

Commit

Permalink
Merge pull request #580 from codesy/auth-changed-header-579
Browse files Browse the repository at this point in the history
for #579: send http header when auth changes
  • Loading branch information
jdungan committed Feb 20, 2018
2 parents f147125 + e07b0f0 commit 6e3e1ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions codesy/base/middleware.py
@@ -0,0 +1,12 @@
AUTH_CHANGING_PATHS = ['/accounts/logout/', '/accounts/github/login/callback/']


class AuthChangedMiddleware(object):
"""
Adds a custom HTTP header for the widget when auth state changes
"""

def process_response(self, request, response):
if request.path in AUTH_CHANGING_PATHS:
response['x-codesy-auth-changed'] = 'true'
return response
1 change: 1 addition & 0 deletions codesy/settings.py
Expand Up @@ -73,6 +73,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'payments.middleware.IdentityVerificationMiddleware',
'codesy.base.middleware.AuthChangedMiddleware'
)


Expand Down

0 comments on commit 6e3e1ef

Please sign in to comment.