Skip to content

Commit

Permalink
Add EdXOAuth2.auth_complete_signal on auth_complete()
Browse files Browse the repository at this point in the history
Also, version bumped to 2.0.2.

This is part of the DOP->DOT migration.
  • Loading branch information
pwnage101 committed Aug 12, 2019
1 parent 7e97bd8 commit 6bf9d85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion auth_backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
These package is designed to be used primarily with Open edX Django projects, but should be compatible with non-edX
projects as well.
"""
__version__ = '2.0.1' # pragma: no cover
__version__ = '2.0.2' # pragma: no cover
13 changes: 13 additions & 0 deletions auth_backends/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ class EdXOAuth2(EdXBackendMixin, BaseOAuth2):
'user_id': 'user_id',
})

# This signal is fired after the user has successfully logged in.
auth_complete_signal = Signal(providing_args=['user'])

@property
def logout_url(self):
if self.setting('LOGOUT_REDIRECT_URL'):
Expand Down Expand Up @@ -295,6 +298,16 @@ def auth_complete_params(self, state=None):
params['token_type'] = 'jwt'
return params

def auth_complete(self, *args, **kwargs):
"""
This method is overwritten to emit the `EdXOAuth2.auth_complete_signal` signal.
"""
# WARNING: During testing, the user model class is `social_core.tests.models.User`,
# not the model specified for the application.
user = super(EdXOAuth2, self).auth_complete(*args, **kwargs)
self.auth_complete_signal.send(sender=self.__class__, user=user)
return user

def user_data(self, access_token, *args, **kwargs):
decoded_access_token = jwt.decode(access_token, verify=False)

Expand Down

0 comments on commit 6bf9d85

Please sign in to comment.