mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-11-10 19:26:35 +03:00
Update configs and changelog for version 0.9.3 + additional fixes
This commit is contained in:
parent
6a84d85d91
commit
bcd6ab4401
|
@ -1,5 +1,5 @@
|
||||||
django>=1.9.0
|
django>=1.9.0
|
||||||
django-rest-auth==0.9.2
|
django-rest-auth==0.9.3
|
||||||
djangorestframework>=3.7.0
|
djangorestframework>=3.7.0
|
||||||
django-allauth>=0.24.1
|
django-allauth>=0.24.1
|
||||||
six==1.9.0
|
six==1.9.0
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
0.9.3
|
||||||
|
-----
|
||||||
|
- added social connect views
|
||||||
|
- added check for pre-existing accounts in social login
|
||||||
|
- prevent double-validation in LoginSerializer
|
||||||
|
- unit tests and demo project changes for Django 2.0
|
||||||
|
|
||||||
0.9.2
|
0.9.2
|
||||||
-----
|
-----
|
||||||
- added permission classes configuration for registration
|
- added permission classes configuration for registration
|
||||||
|
|
|
@ -150,14 +150,14 @@ If you are using Twitter for your social authentication, it is a bit different s
|
||||||
urlpatterns += [
|
urlpatterns += [
|
||||||
...,
|
...,
|
||||||
url(r'^rest-auth/twitter/$', TwitterLogin.as_view(), name='twitter_login')
|
url(r'^rest-auth/twitter/$', TwitterLogin.as_view(), name='twitter_login')
|
||||||
url(r'^rest-auth/twitter/connect/$', TwitterConnect.as_view(), name='twitter_connect')
|
|
||||||
]
|
]
|
||||||
|
|
||||||
.. note:: Starting from v0.21.0, django-allauth has dropped support for context processors. Check out http://django-allauth.readthedocs.org/en/latest/changelog.html#from-0-21-0 for more details.
|
.. note:: Starting from v0.21.0, django-allauth has dropped support for context processors. Check out http://django-allauth.readthedocs.org/en/latest/changelog.html#from-0-21-0 for more details.
|
||||||
|
|
||||||
Additional Social Connect Views
|
Additional Social Connect Views
|
||||||
###############################
|
###############################
|
||||||
|
|
||||||
If you want to allow connecting existing accounts in addition to just login, you can use connect views:
|
If you want to allow connecting existing accounts in addition to login, you can use connect views:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ In urls.py:
|
||||||
url(r'^rest-auth/twitter/connect/$', TwitterConnect.as_view(), name='twitter_connect')
|
url(r'^rest-auth/twitter/connect/$', TwitterConnect.as_view(), name='twitter_connect')
|
||||||
]
|
]
|
||||||
|
|
||||||
You can also use additional views to check all social accounts attached to the current authenticated user and disconnect selected social accounts.
|
You can also use the following views to check all social accounts attached to the current authenticated user and disconnect selected social accounts:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
|
@ -8,15 +9,19 @@ try:
|
||||||
get_username_max_length)
|
get_username_max_length)
|
||||||
from allauth.account.adapter import get_adapter
|
from allauth.account.adapter import get_adapter
|
||||||
from allauth.account.utils import setup_user_email
|
from allauth.account.utils import setup_user_email
|
||||||
from allauth.socialaccount.helpers import complete_social_login
|
|
||||||
from allauth.socialaccount.models import SocialAccount
|
|
||||||
from allauth.socialaccount.providers.base import AuthProcess
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError("allauth needs to be added to INSTALLED_APPS.")
|
raise ImportError("allauth needs to be added to INSTALLED_APPS.")
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from requests.exceptions import HTTPError
|
from requests.exceptions import HTTPError
|
||||||
|
|
||||||
|
# Import is needed only if we are using social login, in which
|
||||||
|
# case the allauth.socialaccount will be declared
|
||||||
|
if 'allauth.socialaccount' in settings.INSTALLED_APPS:
|
||||||
|
from allauth.socialaccount.helpers import complete_social_login
|
||||||
|
from allauth.socialaccount.models import SocialAccount
|
||||||
|
from allauth.socialaccount.providers.base import AuthProcess
|
||||||
|
|
||||||
|
|
||||||
class SocialAccountSerializer(serializers.ModelSerializer):
|
class SocialAccountSerializer(serializers.ModelSerializer):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -322,10 +322,6 @@ class TestSocialConnectAuth(TestsMixin, TestCase):
|
||||||
"password2": PASS,
|
"password2": PASS,
|
||||||
"email": EMAIL
|
"email": EMAIL
|
||||||
}
|
}
|
||||||
LOGIN_DATA = {
|
|
||||||
"username": USERNAME,
|
|
||||||
"password": PASS,
|
|
||||||
}
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.init()
|
self.init()
|
||||||
|
@ -405,9 +401,6 @@ class TestSocialConnectAuth(TestsMixin, TestCase):
|
||||||
self.assertIn('key', self.response.json.keys())
|
self.assertIn('key', self.response.json.keys())
|
||||||
|
|
||||||
# Test Twitter
|
# Test Twitter
|
||||||
self.post(self.logout_url)
|
|
||||||
self.post(self.login_url, data=self.LOGIN_DATA)
|
|
||||||
|
|
||||||
resp_body = {
|
resp_body = {
|
||||||
"id": "123123123123",
|
"id": "123123123123",
|
||||||
}
|
}
|
||||||
|
@ -439,7 +432,7 @@ class TestSocialConnectAuth(TestsMixin, TestCase):
|
||||||
|
|
||||||
# Try disconnecting accounts
|
# Try disconnecting accounts
|
||||||
self.incorrect_disconnect_url = reverse(
|
self.incorrect_disconnect_url = reverse(
|
||||||
'social_account_disconnect', args=[999]
|
'social_account_disconnect', args=[999999999]
|
||||||
)
|
)
|
||||||
self.post(self.incorrect_disconnect_url, status_code=404)
|
self.post(self.incorrect_disconnect_url, status_code=404)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user