Same messages in creation/deletion preventing scape chars errors in password

This commit is contained in:
wcolmenares 2019-05-06 11:42:58 -04:00
parent 9711dc1ecc
commit 9576ae9064
1 changed files with 4 additions and 2 deletions

View File

@ -615,11 +615,13 @@ class SeedRetrieveCreate(APIView):
def post(self, request):
try:
username = request.data['username']
password = request.data['password']
password = request.data[r'password']
realm = request.data['realm']
print(password)
except KeyError:
return Response('You need to specify username, password, and realm values', 400)
# authenticate the user against ldap
user = authenticate(username=username, password=password)
if user is not None:
admin_seed = config('ADMIN_SEED')
@ -636,7 +638,7 @@ class SeedRetrieveCreate(APIView):
for elem in response_data:
if elem['name'] == username and elem['realm'] == realm:
return Response('Your {} seed is {}'.format(realm, elem['seed']), 200)
return Response(elem, 200)
# If doesn't find a match then check if the realm is allowed and create the user
allowed_realms = config('ALLOWED_REALMS', cast=Csv())
if realm not in allowed_realms: