Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@
History
=======

0.1.0 (2022-02-02)
0.1.2 (2022-02-26)
------------------

* First release on PyPI.

* Authentication with github.
* Create user account with github.
* Track state.
* Added ``github_user_created`` signal.

0.1.1 (2022-02-04)
------------------

* Minor updates.

* No explicit ``makemigrations`` required.

0.1.0 (2022-02-02)
------------------

* First release on PyPI.

* Authentication with github.
* Create user account with github.
* Track state.
2 changes: 1 addition & 1 deletion django_rest_github_oauth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """Abdullah Adeel"""
__email__ = 'business.info.abd@gmail.com'
__version__ = '0.1.1'
__version__ = '0.1.2'
5 changes: 4 additions & 1 deletion django_rest_github_oauth/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from django.contrib.auth.models import User
from rest_framework.exceptions import AuthenticationFailed

from django_rest_github_oauth.signals import github_user_created

from .models import GitHubAccount
from .response import UserResponse
from .utils import id_generator
Expand All @@ -24,7 +26,7 @@ def generate_username(name: str) -> str:
def get_names(user_data: dict) -> Tuple:
name: str = user_data.get("name")
names: list = name.split(" ")
return names[0], names[1]
return names[0], names[1] if len(names) > 1 else ""

def register_social_user(provider: str, user_data: dict) -> str:
filtering_by_email = get_user_model().objects.filter(email=user_data.get("email"))
Expand All @@ -50,4 +52,5 @@ def register_social_user(provider: str, user_data: dict) -> str:

GitHubAccount.objects.create(user=user).save()
user.save()
github_user_created.send(sender=None, user=user)
return UserResponse.get_user_payload(user)
3 changes: 3 additions & 0 deletions django_rest_github_oauth/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.dispatch import Signal

github_user_created = Signal(providing_args=["user"])
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Contents:

Getting Started<readme>
installation
usage
signals
contributing
authors
history
Expand Down
23 changes: 23 additions & 0 deletions docs/signals.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Signals
========


``django-rest-github-oauth`` provides the following signals:

``github_user_created``
-----------------------
Sent when a new GitHub user is created. The signal is sent with the
newly created user instance as one of the keywords arguments.
The user is instance of default User model specified in ``settings.py``.

.. code-block:: python

from django.contrib.auth.models import User
from django.dispatch import receiver
from rest_github_oauth.signals import github_user_created

@receiver(github_user_created)
def my_callback(sender, **kwargs):
user: User = kwargs['user']
# do something with the user
# ...
7 changes: 0 additions & 7 deletions docs/usage.rst

This file was deleted.

2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.1
current_version = 0.1.2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/mabdullahadeel/django-rest-github-oauth',
version='0.1.1',
version='0.1.2',
zip_safe=False,
)