Skip to content

Commit

Permalink
Bump new version
Browse files Browse the repository at this point in the history
  • Loading branch information
artinnok committed Feb 7, 2022
1 parent 1edaad6 commit 42542e5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ pip install django-swap-user
## Basic usage
1. Choose one of models and settings from table:

| Application name | Username field | Description | `INSTALLED_APPS` | `AUTH_USER_MODEL` |
| Application name | Username field | Description | `INSTALLED_APPS` | `AUTH_USER_MODEL` |
|------------------|----------------|-----------------------------------------------------------------------|------------------------------------------------|-----------------------------------|
| `to_email` | `email` | User with `email` username | ```"swap_user", "swap_user.to_email",``` | `"to_email.EmailUser"` |
| `to_named_email` | `email` | User with `email` username, `first_name` and `last_name` extra fields | ```"swap_user", "swap_user.to_named_email",``` | `"to_named_email.NamedEmailUser"` |
| `to_phone` | `phone` | User with `phone` username | ```"swap_user", "swap_user.to_phone",``` | `"to_phone.PhoneUser"` |
| `to_phone_otp` | `phone` | User with `phone` username and OTP authentication | ```"swap_user", "swap_user.to_phone_otp",``` | `"to_phone.PhoneOTPUser"` |

2. Add corresponding app to `INSTALLED_APPS`:
```python
Expand All @@ -39,6 +40,7 @@ Application `swap_user` split into 3 apps:
- `to_email` - provides user with `email` username field
- `to_named_email` - provides user with `email` username field and with `first_name`, `last_name` extra fields
- `to_phone` - provides user with `phone` username field
- `to_phone_otp` - provides user with `phone` username field and with OTP authentication


## Why?
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lines_after_imports = 2

[tool.poetry]
name = "django-swap-user"
version = "0.4.1"
version = "0.5.0"
description = "(Beta) Simple and flexible way to swap default Django User"
authors = ["Artem Innokentiev <[email protected]>"]
maintainers = ["Artem Innokentiev <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion swap_user/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

__title__ = "Django Swap User"
__version__ = "0.4.1"
__version__ = "0.5.0"
__author__ = "Artem Innokentiev"
__license__ = "MIT"
__copyright__ = "Copyright 2021 © Artem Innokentiev"
Expand Down
6 changes: 4 additions & 2 deletions swap_user/to_phone_otp/auth_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def authenticate(self, request, phone: str, otp_from_user: str, **credentials):
Authenticates used based on OTP (One Time Password) because current user model
doesn't have a `password` field.
Reference - Reference - https://docs.djangoproject.com/en/dev/topics/auth/customizing/#writing-an-authentication-backend
Reference - https://docs.djangoproject.com/en/dev/topics/auth/customizing/#writing-an-authentication-backend
"""

try:
Expand All @@ -35,6 +35,8 @@ def get_user(self, user_id: int):
"""

try:
return PhoneOTPUser.objects.get(pk=user_id)
user = PhoneOTPUser.objects.get(pk=user_id)

return user
except PhoneOTPUser.DoesNotExist:
return None

0 comments on commit 42542e5

Please sign in to comment.