Skip to content

Commit

Permalink
USERS :: Fix : Fix api for Python3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
KGuillemot committed Jun 9, 2020
1 parent 08763ff commit 3919a33
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions api/views/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ def post(self, request, repo_id, login=""):
if not password:
return JsonResponse({'status': False, 'error': "Password missing in POST data."})

login = login.encode("utf-8")
password = password.encode("utf-8")
email = request_data.get('email', "").encode('utf-8')
phone = request_data.get('phone', "").encode('utf-8')
login = login
password = password
email = request_data.get('email', "")
phone = request_data.get('phone', "")

kwargs = {}
if isinstance(repo, LDAPRepository):
Expand All @@ -124,7 +124,7 @@ def post(self, request, repo_id, login=""):
if not group:
return JsonResponse({'status': False, 'error': "Group is missing for adding user into LDAP repository."})
else:
group = group.encode('utf-8')
group = group
kwargs['group'] = group
kwargs['update_group'] = update_group

Expand Down Expand Up @@ -164,22 +164,22 @@ def put(self, request, repo_id, login=""):
# Check if fields are correctly filled-in
request_data = request.POST or request.JSON

login = login.encode("utf-8")
login = login
email = request_data.get('email')
phone = request_data.get('phone')
password = request_data.get('password')
if not email and not phone and not password:
return JsonResponse({'status': False, 'error': "Password, Email and Phone missing in POST data. "
"Nothing to do."})
if email:
email = email.encode('utf-8')
email = email
if phone:
phone = phone.encode('utf-8')
phone = phone
if email or phone:
backend.update_user(login, email=email, phone=phone)

if password:
password = password.encode('utf-8')
password = password
backend.change_password(login, "", password)

return JsonResponse({
Expand Down

0 comments on commit 3919a33

Please sign in to comment.