Skip to content

Commit

Permalink
case-insensitive aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronn committed Jun 13, 2020
1 parent dca848a commit b5fcc2c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion drfpasswordless/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

__title__ = 'drfpasswordless'
__version__ = '1.5.3'
__version__ = '1.5.4'
__author__ = 'Aaron Ng'
__license__ = 'MIT'
__copyright__ = 'Copyright 2020 Aaron Ng'
Expand Down
2 changes: 1 addition & 1 deletion drfpasswordless/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = (1, 5, 3)
VERSION = (1, 5, 4)

__version__ = '.'.join(map(str, VERSION))
14 changes: 7 additions & 7 deletions drfpasswordless/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ def validate(self, attrs):

if api_settings.PASSWORDLESS_REGISTER_NEW_USERS is True:
# If new aliases should register new users.
user, user_created = User.objects.get_or_create(
**{self.alias_type: alias})

if user_created:
try:
user = User.objects.get(**{self.alias_type+'__iexact': alias})
except User.DoesNotExist:
user = User.objects.create(**{self.alias_type: alias})
user.set_unusable_password()
user.save()
else:
# If new aliases should not register new users.
try:
user = User.objects.get(**{self.alias_type: alias})
user = User.objects.get(**{self.alias_type+'__iexact': alias})
except User.DoesNotExist:
user = None

Expand Down Expand Up @@ -202,7 +202,7 @@ def validate(self, attrs):
try:
alias_type, alias = self.validate_alias(attrs)
callback_token = attrs.get('token', None)
user = User.objects.get(**{alias_type: alias})
user = User.objects.get(**{alias_type+'__iexact': alias})
token = CallbackToken.objects.get(**{'user': user,
'key': callback_token,
'type': CallbackToken.TOKEN_TYPE_AUTH,
Expand Down Expand Up @@ -252,7 +252,7 @@ def validate(self, attrs):
try:
alias_type, alias = self.validate_alias(attrs)
user_id = self.context.get("user_id")
user = User.objects.get(**{'id': user_id, alias_type: alias})
user = User.objects.get(**{'id': user_id, alias_type+'__iexact': alias})
callback_token = attrs.get('token', None)

token = CallbackToken.objects.get(**{'user': user,
Expand Down

0 comments on commit b5fcc2c

Please sign in to comment.