Skip to content

Commit 3c6c675

Browse files
committed
Fix account creation error
Changes to be committed: modified: bco_api/api/views.py modified: bco_api/bco_api/settings.py
1 parent a38b870 commit 3c6c675

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed

bco_api/api/views.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ApiAccountsActivateUsernameTempIdentifier(APIView):
117117
other users to act as the verification layer in addition to the system.
118118
119119
"""
120-
authentication_classes = ['Bearer']
120+
authentication_classes = []
121121
permission_classes = []
122122

123123
# For the success and error messages
@@ -171,7 +171,7 @@ class ApiAccountsDescribe(APIView):
171171

172172
auth = [
173173
openapi.Parameter('Authorization',
174-
openapi.IN_HEADER,
174+
openapi.IN_HEADER,
175175
description="Authorization Token",
176176
type=openapi.TYPE_STRING
177177
)
@@ -372,10 +372,12 @@ class ApiAccountsNew(APIView):
372372
373373
--------------------
374374
375-
Ask for a new account. Sends an e-mail to the provided e-mail, which must then be clicked to activate the account.
375+
Ask for a new account. Sends an e-mail to the provided e-mail, which must
376+
then be clicked to activate the account.
376377
377-
The account create depends on creation of an account in the associated user database. The authentication as
378-
well as the user database host information is used to make this request.
378+
The account create depends on creation of an account in the associated
379+
user database. The authentication as well as the user database host
380+
information is used to make this request.
379381
380382
```JSON
381383
{
@@ -385,7 +387,7 @@ class ApiAccountsNew(APIView):
385387
}
386388
```
387389
"""
388-
390+
389391
# Anyone can ask for a new account
390392
authentication_classes = []
391393
permission_classes = []
@@ -410,6 +412,7 @@ class ApiAccountsNew(APIView):
410412
500: "Unable to save the new account or send authentication email."
411413
}, tags=["Account Management"])
412414
def post(self, request) -> Response:
415+
import pdb; pdb.set_trace()
413416
print("Request: {}".format(request))
414417
return check_post_and_process(request, POST_api_accounts_new)
415418

bco_api/bco_api/settings.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
"""
99

1010
import os
11-
12-
# For importing schema
13-
from api.scripts.utilities import SettingsUtils
14-
1511
# For importing configuration files
1612
import configparser
13+
# For importing schema
14+
from api.scripts.utilities import SettingsUtils
1715

1816
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1917
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -50,7 +48,7 @@
5048
# Source: https://dzone.com/articles/how-to-fix-django-cors-error
5149

5250
# Check for open (public) access to the API.
53-
if(server_config['REQUESTS_FROM']['public'].strip() == 'false'):
51+
if server_config['REQUESTS_FROM']['public'].strip() == 'false':
5452

5553
# Process the requester groups.
5654

@@ -63,16 +61,16 @@
6361
# Flatten the list.
6462
# Source: https://stackabuse.com/python-how-to-flatten-list-of-lists/
6563
flattened = [item.strip() for sublist in requesters for item in sublist]
66-
64+
6765
if server_config['PRODUCTION']['production'] == 'True':
6866
ALLOWED_HOSTS = [i.strip() for i in server_config['HOSTNAMES']['prod_names'].split(',')]
6967
elif server_config['PRODUCTION']['production'] == 'False':
7068
ALLOWED_HOSTS = [i.strip() for i in server_config['HOSTNAMES']['names'].split(',')]
71-
69+
7270
CORS_ORIGIN_ALLOW_ALL = False
7371
CORS_ORIGIN_WHITELIST = tuple(flattened)
74-
75-
elif(server_config['REQUESTS_FROM']['public'].strip() == 'true'):
72+
73+
elif server_config['REQUESTS_FROM']['public'].strip() == 'true':
7674
if server_config['PRODUCTION']['production'] == 'True':
7775
ALLOWED_HOSTS = [server_config['HOSTNAMES']['prod_names'].split(',')[0],'*']
7876
CORS_ORIGIN_ALLOW_ALL = True
@@ -90,7 +88,7 @@
9088
'DEFAULT_PERMISSION_CLASSES': [
9189
'rest_framework.permissions.IsAuthenticated'
9290
],
93-
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
91+
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
9492
}
9593

9694
# Password validation
@@ -218,16 +216,9 @@
218216
STATIC_ROOT = '/var/www/bcoeditor/bco_api/bco_api/static/'
219217

220218
# ----- CUSTOM VARIABLES AND METHODS ----- #
221-
222-
223-
224-
225219
# Load request and validation templates (definitions).
226-
227220
# Note that we will get TWO loads of settings.py if we start without runserver --noreload
228-
229221
# There is only set of definitions for requests, but for validations, we may have sub-folders.
230-
231222
# First, the request definitions.
232223
REQUEST_TEMPLATES = SettingsUtils.SettingsUtils().load_schema_local(search_parameters={
233224
'request_definitions/': '.schema'
@@ -248,14 +239,14 @@
248239
OBJECT_NAMING = {}
249240

250241
if server_config['PRODUCTION']['production'] == 'True':
251-
242+
252243
for i in server_config['OBJECT_NAMING']:
253244
if i.split('_')[0] == 'prod':
254-
245+
255246
# Strip out the production flag.
256-
stripped = '_'.join(i.split('_')[1:])
257-
258-
OBJECT_NAMING[stripped] = server_config['OBJECT_NAMING'][i]
247+
STRIPPED = '_'.join(i.split('_')[1:])
248+
249+
OBJECT_NAMING[STRIPPED] = server_config['OBJECT_NAMING'][i]
259250

260251
elif server_config['PRODUCTION']['production'] == 'False':
261252

@@ -269,4 +260,3 @@
269260
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
270261
EMAIL_HOST = 'localhost'
271262
EMAIL_PORT = 25
272-

0 commit comments

Comments
 (0)