Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Commit

Permalink
fixed bug: if user deleted all oterMailbox alias in the edit page, th…
Browse files Browse the repository at this point in the history
…en after was imposible to add more
  • Loading branch information
Carlos-err406 committed Mar 28, 2022
1 parent 918400e commit 178e1cd
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions plugins/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,12 @@ def user_add():
attributes[attribute] = [str(current_uac).encode('utf-8')]
elif attribute == 'otherMailbox':
alias_list = list(filter(None, request.form.getlist('alias_mail')))
print(alias_list)
if len(alias_list):
for i in range(0, len(alias_list)):
alias_list[i] = alias_list[i].encode('utf-8')
attributes[attribute] = alias_list
else:
attributes[attribute] = [b'0'] #it needs to have an element
print(attributes)
elif attribute and field.data:
if isinstance(field, BooleanField):
if field.data:
Expand Down Expand Up @@ -410,6 +408,9 @@ def user_edit_profile(username):
ldap_update_attribute(user['distinguishedName'], 'displayName', displayName)
elif attribute == 'otherMailbox':
alias_list = list(filter(None, request.form.getlist('alias_mail')))
if len(alias_list) == 0:
print('here..alias_list len is 0')
alias_list = ['0']
print(alias_list)
ldap_update_attribute(user['distinguishedName'], attribute, alias_list)
else:
Expand All @@ -429,13 +430,10 @@ def user_edit_profile(username):
form.last_name.data = user.get('sn')
form.user_name.data = user.get('sAMAccountName')
form.mail.data = user.get('mail')
print(user.get('otherMailbox'))
if user.get('otherMailbox') is not None:
othermails = user.get('otherMailbox')
print('here1')
else:
othermails = []
print('here2')
form.uac_flags.data = [key for key, flag in
LDAP_AD_USERACCOUNTCONTROL_VALUES.items()
if (flag[1] and
Expand Down

0 comments on commit 178e1cd

Please sign in to comment.