Skip to content

Commit

Permalink
Merge 4b056a9 into 7b28e72
Browse files Browse the repository at this point in the history
  • Loading branch information
lnielsen committed Jul 28, 2016
2 parents 7b28e72 + 4b056a9 commit 3e92878
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Changes
=======

Version 1.0.0a7 (released 2016-07-07)
Version 1.0.0a8 (released 2016-07-27)
-------------------------------------

- Refactoring for Invenio 3.
Expand Down
6 changes: 3 additions & 3 deletions RELEASE-NOTES.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
==============================
Invenio-OAuthClient v1.0.0a7
Invenio-OAuthClient v1.0.0a8
==============================

Invenio-OAuthClient v1.0.0a7 was released on July 7, 2016.
Invenio-OAuthClient v1.0.0a8 was released on July 27, 2016.

About
-----
Expand All @@ -19,7 +19,7 @@ What's new
Installation
------------

$ pip install invenio-oauthclient==1.0.0a7
$ pip install invenio-oauthclient==1.0.0a8

Documentation
-------------
Expand Down
19 changes: 13 additions & 6 deletions invenio_oauthclient/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
OAuthRejectedRequestError, OAuthResponseError
from .models import RemoteAccount, RemoteToken
from .proxies import current_oauthclient
from .signals import account_info_received, account_setup_received
from .signals import account_info_received, account_setup_committed, \
account_setup_received
from .utils import disable_csrf, fill_form, oauth_authenticate, \
oauth_get_user, oauth_register, registrationform_cls

Expand Down Expand Up @@ -245,7 +246,7 @@ def authorized_signup_handler(resp, remote, *args, **kwargs):
)
user = oauth_register(form)

# if registration fails..
# if registration fails ...
if user is None:
# requires extra information
session[
Expand Down Expand Up @@ -281,10 +282,13 @@ def authorized_signup_handler(resp, remote, *args, **kwargs):
account_setup_received.send(
remote, token=token, response=resp, account_setup=account_setup
)
db.session.commit()
account_setup_committed.send(remote, token=token)
else:
db.session.commit()

# Redirect to next
next_url = get_session_next_url(remote.name)
db.session.commit()
if next_url:
return redirect(next_url)
return redirect(url_for('invenio_oauthclient_settings.index'))
Expand Down Expand Up @@ -358,9 +362,12 @@ def signup_handler(remote, *args, **kwargs):
remote, token=token, response=response,
account_setup=account_setup
)

# Registration has been finished
db.session.commit()
# Registration has been finished
db.session.commit()
account_setup_committed.send(remote, token=token)
else:
# Registration has been finished
db.session.commit()

# Authenticate the user
if not oauth_authenticate(remote.consumer_key, user,
Expand Down
19 changes: 19 additions & 0 deletions invenio_oauthclient/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,22 @@ def load_extra_information(remote, token=None, response=None,
# process response
"""


account_setup_committed = _signals.signal(
'oauthclient-account-setup-committed')
"""Signal is sent after account setup has been committed to database.
Example subscriber:
.. code-block:: python
from invenio_oauthclient.signals import account_setup_committed
# During overlay initialization.
@account_setup_committed.connect
def fetch_info(remote):
response = remote.get('https://example.org/api/resource')
# process response
"""
2 changes: 1 addition & 1 deletion invenio_oauthclient/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
and parsed by ``setup.py``.
"""

__version__ = '1.0.0a8.dev20160708'
__version__ = '1.0.0a8'

0 comments on commit 3e92878

Please sign in to comment.