DEBUG from env

This commit is contained in:
mahdavi 2020-03-10 11:03:50 +03:30
parent e4436b9e78
commit b819a11ba8
3 changed files with 14 additions and 4 deletions

View file

@ -1,6 +1,7 @@
import random
from datetime import timedelta
from django.conf import settings
from django.contrib.auth.base_user import BaseUserManager
from django.contrib.auth.models import AbstractUser
from django.contrib.auth.validators import UnicodeUsernameValidator
@ -110,9 +111,9 @@ class User(AbstractUser):
objects = UserManager()
def set_otp(self):
self.otp = '12345'
if self.phone_number in DEVELOPMENT_PHONE_NUMBERS:
if settings.DEBUG or self.phone_number in DEVELOPMENT_PHONE_NUMBERS:
self.otp = '12345'
else:
self.otp = ''.join(random.choice('0123456789') for _ in range(5))

View file

@ -22,7 +22,7 @@ class ApiClient():
"grant_type": "password",
"username": phone_number,
"password": password,
"scope": 'read write groups',
"scope": 'read write groups introspection',
"auth_gateway": 'phone_number:otp'
}
auth = (OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET)
@ -145,3 +145,12 @@ class ApiClient():
def receipt_transaction(self, code):
path = f'transactions/{code}/receipt'
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)

View file

@ -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'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = config('DEBUG', False, cast=bool)
ALLOWED_HOSTS = ['*']