ldap: Minor styling fixes

This commit is contained in:
Sunil Mohan Adapa 2015-06-25 23:40:24 +05:30
parent bc8523d9a3
commit 82090af423
5 changed files with 15 additions and 6 deletions

View File

@ -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:

View File

@ -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

View File

@ -31,7 +31,7 @@
{% endif %}
{% if is_ldap_user %}
<p>This user is also an LDAP user. LDAP user will also be deleted.</p>
<p>This user is also an LDAP user. LDAP user will also be deleted.</p>
{% endif %}
<p>Delete user permanently?</p>

View File

@ -53,7 +53,7 @@
{% endif %}
{% if is_ldap_user %}
<p>This user is also an LDAP user.</p>
<p>This user is also an LDAP user.</p>
{% endif %}
<input type="submit" class="btn btn-primary" value="Save Changes"/>

View File

@ -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'])