DEBUG from env
This commit is contained in:
parent
e4436b9e78
commit
b819a11ba8
3 changed files with 14 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import random
|
import random
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.auth.base_user import BaseUserManager
|
from django.contrib.auth.base_user import BaseUserManager
|
||||||
from django.contrib.auth.models import AbstractUser
|
from django.contrib.auth.models import AbstractUser
|
||||||
from django.contrib.auth.validators import UnicodeUsernameValidator
|
from django.contrib.auth.validators import UnicodeUsernameValidator
|
||||||
|
|
@ -110,9 +111,9 @@ class User(AbstractUser):
|
||||||
objects = UserManager()
|
objects = UserManager()
|
||||||
|
|
||||||
def set_otp(self):
|
def set_otp(self):
|
||||||
|
if settings.DEBUG or self.phone_number in DEVELOPMENT_PHONE_NUMBERS:
|
||||||
self.otp = '12345'
|
self.otp = '12345'
|
||||||
if self.phone_number in DEVELOPMENT_PHONE_NUMBERS:
|
|
||||||
self.otp = '12345'
|
|
||||||
else:
|
else:
|
||||||
self.otp = ''.join(random.choice('0123456789') for _ in range(5))
|
self.otp = ''.join(random.choice('0123456789') for _ in range(5))
|
||||||
|
|
||||||
|
|
|
||||||
11
client.py
11
client.py
|
|
@ -22,7 +22,7 @@ class ApiClient():
|
||||||
"grant_type": "password",
|
"grant_type": "password",
|
||||||
"username": phone_number,
|
"username": phone_number,
|
||||||
"password": password,
|
"password": password,
|
||||||
"scope": 'read write groups',
|
"scope": 'read write groups introspection',
|
||||||
"auth_gateway": 'phone_number:otp'
|
"auth_gateway": 'phone_number:otp'
|
||||||
}
|
}
|
||||||
auth = (OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET)
|
auth = (OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET)
|
||||||
|
|
@ -145,3 +145,12 @@ class ApiClient():
|
||||||
def receipt_transaction(self, code):
|
def receipt_transaction(self, code):
|
||||||
path = f'transactions/{code}/receipt'
|
path = f'transactions/{code}/receipt'
|
||||||
return self._request(path=path)
|
return self._request(path=path)
|
||||||
|
|
||||||
|
def get_introspection(self):
|
||||||
|
path = 'oauth2/introspect/'
|
||||||
|
access_token = self.auth_data.get('access_token', '')
|
||||||
|
data = {
|
||||||
|
'token': access_token,
|
||||||
|
}
|
||||||
|
return self._request(path=path, data=data)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
SECRET_KEY = 'tm9-y*5r=n028ii8iny#u1p3&mdjqf-#kj!z^fg%sbussj@r+o'
|
SECRET_KEY = 'tm9-y*5r=n028ii8iny#u1p3&mdjqf-#kj!z^fg%sbussj@r+o'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = config('DEBUG', False, cast=bool)
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ['*']
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue