diff --git a/actions/xmpp b/actions/xmpp index 0b5a5125b..9043be126 100755 --- a/actions/xmpp +++ b/actions/xmpp @@ -148,6 +148,7 @@ def subcommand_enable_ldap(_): """Enable LDAP authentication""" with open(EJABBERD_CONFIG, 'r') as conffile: lines = conffile.readlines() + with open(EJABBERD_CONFIG, 'w') as conffile: for line in lines: if 'auth_method: internal' in line: @@ -161,6 +162,7 @@ def subcommand_enable_ldap(_): conffile.write('ldap_base: "ou=users,dc=thisbox"\n') else: conffile.write(line) + try: subprocess.check_output(['ejabberdctl', 'restart']) except subprocess.CalledProcessError as err: @@ -171,6 +173,7 @@ def subcommand_disable_ldap(_): """Disable LDAP authentication""" with open(EJABBERD_CONFIG, 'r') as conffile: lines = conffile.readlines() + with open(EJABBERD_CONFIG, 'w') as conffile: for line in lines: if '## auth_method: internal' in line: @@ -179,6 +182,7 @@ def subcommand_disable_ldap(_): conffile.write('## auth_method: ldap\n') else: conffile.write(line) + try: subprocess.check_output(['ejabberdctl', 'restart']) except subprocess.CalledProcessError as err: @@ -196,12 +200,14 @@ def subcommand_enable_inband(_): """Enable inband registration""" with open(EJABBERD_CONFIG, 'r') as conffile: lines = conffile.readlines() + with open(EJABBERD_CONFIG, 'w') as conffile: for line in lines: if 'ip_access' in line: conffile.write(line.replace('trusted_network', 'all')) else: conffile.write(line) + try: subprocess.check_output(['ejabberdctl', 'restart']) except subprocess.CalledProcessError as err: @@ -212,12 +218,14 @@ def subcommand_disable_inband(_): """Disable inband registration""" with open(EJABBERD_CONFIG, 'r') as conffile: lines = conffile.readlines() + with open(EJABBERD_CONFIG, 'w') as conffile: for line in lines: if 'ip_access' in line: conffile.write(line.replace('all', 'trusted_network')) else: conffile.write(line) + try: subprocess.check_output(['ejabberdctl', 'restart']) except subprocess.CalledProcessError as err: diff --git a/plinth/modules/users/forms.py b/plinth/modules/users/forms.py index acb027bef..c2c2a88cb 100644 --- a/plinth/modules/users/forms.py +++ b/plinth/modules/users/forms.py @@ -26,9 +26,9 @@ from plinth.errors import ActionError class CreateUserForm(UserCreationForm): - """Custom user create form + """Custom user create form. - Includes options to also create POSIX and LDAP user. + Include options to also create POSIX and LDAP user. """ add_posix_user = forms.BooleanField( @@ -62,6 +62,7 @@ class CreateUserForm(UserCreationForm): except ActionError: messages.error(self.request, _('Creating POSIX system user failed.')) + if self.cleaned_data['add_ldap_user']: try: actions.superuser_run( @@ -114,12 +115,14 @@ class UserUpdateForm(forms.ModelForm): except ActionError: messages.error(self.request, _('Renaming POSIX system user failed.')) + try: actions.superuser_run('rename-ldap-user', [self.username, user.get_username()]) except ActionError: messages.error(self.request, _('Renaming LDAP user failed.')) + return user diff --git a/plinth/modules/users/templates/users_delete.html b/plinth/modules/users/templates/users_delete.html index 746e729fb..95b17f402 100644 --- a/plinth/modules/users/templates/users_delete.html +++ b/plinth/modules/users/templates/users_delete.html @@ -31,7 +31,7 @@ {% endif %} {% if is_ldap_user %} -
This user is also an LDAP user. LDAP user will also be deleted.
+This user is also an LDAP user. LDAP user will also be deleted.
{% endif %}Delete user permanently?
diff --git a/plinth/modules/users/templates/users_update.html b/plinth/modules/users/templates/users_update.html index b1d0a0b2b..2a6520a71 100644 --- a/plinth/modules/users/templates/users_update.html +++ b/plinth/modules/users/templates/users_update.html @@ -53,7 +53,7 @@ {% endif %} {% if is_ldap_user %} -This user is also an LDAP user.
+This user is also an LDAP user.
{% endif %} diff --git a/plinth/modules/xmpp/xmpp.py b/plinth/modules/xmpp/xmpp.py index dcbba9e3c..f44104299 100644 --- a/plinth/modules/xmpp/xmpp.py +++ b/plinth/modules/xmpp/xmpp.py @@ -146,7 +146,6 @@ def _apply_changes(request, old_status, new_status): output) else: messages.success(request, _('LDAP authentication enabled')) - elif old_status['ldap_enabled'] and not new_status['ldap_enabled']: setting_changed = True output = actions.superuser_run('xmpp', ['disable-ldap']) @@ -166,7 +165,6 @@ def _apply_changes(request, old_status, new_status): output) else: messages.success(request, _('Inband registration enabled')) - elif old_status['inband_enabled'] and not new_status['inband_enabled']: setting_changed = True output = actions.superuser_run('xmpp', ['disable-inband'])