diff --git a/actions/xmpp b/actions/xmpp index da357d730..459fda594 100755 --- a/actions/xmpp +++ b/actions/xmpp @@ -53,18 +53,6 @@ def parse_arguments(): # Setup jwchat apache conf subparsers.add_parser('setup', help='Setup jwchat apache conf') - # Get whether LDAP authentication is enabled - subparsers.add_parser('is-ldap-enabled', - help='Get whether LDAP authentication is enabled') - - # Enable LDAP authentication - subparsers.add_parser('enable-ldap', - help='Enable LDAP authentication') - - # Disable LDAP authentication - subparsers.add_parser('disable-ldap', - help='Disable LDAP authentication') - # Get whether inband registration is enabled subparsers.add_parser('is-inband-enabled', help='Get whether inband registration is enabled') @@ -134,21 +122,7 @@ def subcommand_pre_install(arguments): def subcommand_setup(_): - """Setup jwchat apache conf""" - with action_utils.WebserverChange() as webserver_change: - webserver_change.disable('jwchat', kind='site') - webserver_change.enable('jwchat-plinth') - - -def subcommand_is_ldap_enabled(_): - """Get whether LDAP authentication is enabled""" - conffile = open(EJABBERD_CONFIG, 'r') - conf = yaml.safe_load(conffile) - print('ldap' in conf['auth_method']) - - -def subcommand_enable_ldap(_): - """Enable LDAP authentication""" + """Enabled LDAP authentication and setup jwchat apache conf""" with open(EJABBERD_CONFIG, 'r') as conffile: lines = conffile.readlines() @@ -171,25 +145,9 @@ def subcommand_enable_ldap(_): except subprocess.CalledProcessError as err: print('Failed to restart ejabberd with new configuration: %s', err) - -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: - conffile.write('auth_method: internal\n') - elif 'auth_method: ldap' in line: - conffile.write('## auth_method: ldap\n') - else: - conffile.write(line) - - try: - subprocess.check_output(['ejabberdctl', 'restart']) - except subprocess.CalledProcessError as err: - print('Failed to restart ejabberd with new configuration: %s', err) + with action_utils.WebserverChange() as webserver_change: + webserver_change.disable('jwchat', kind='site') + webserver_change.enable('jwchat-plinth') def subcommand_is_inband_enabled(_): diff --git a/plinth/modules/xmpp/xmpp.py b/plinth/modules/xmpp/xmpp.py index 121551469..f66164103 100644 --- a/plinth/modules/xmpp/xmpp.py +++ b/plinth/modules/xmpp/xmpp.py @@ -86,10 +86,6 @@ def index(request): class ConfigureForm(forms.Form): # pylint: disable-msg=W0232 """Configuration form""" - ldap_enabled = forms.BooleanField( - label=_('Use LDAP for authentication'), required=False, - help_text=_('When enabled, only LDAP users will be able to login to \ -the XMPP service')) inband_enabled = forms.BooleanField( label=_('Allow In-Band Registration'), required=False, help_text=_('When enabled, anyone who can reach this server will be \ @@ -120,12 +116,9 @@ def configure(request): def get_status(): """Return the current status""" - output = actions.run('xmpp', ['is-ldap-enabled']) - ldap_enabled = 'True' in output.split() output = actions.run('xmpp', ['is-inband-enabled']) inband_enabled = 'True' in output.split() - return {'ldap_enabled': ldap_enabled, - 'inband_enabled': inband_enabled} + return {'inband_enabled': inband_enabled} def _apply_changes(request, old_status, new_status): @@ -134,25 +127,6 @@ def _apply_changes(request, old_status, new_status): setting_changed = False - if not old_status['ldap_enabled'] and new_status['ldap_enabled']: - setting_changed = True - output = actions.superuser_run('xmpp', ['enable-ldap']) - if 'Failed' in output: - messages.error(request, - _('Error when configuring XMPP server: %s') % - 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']) - if 'Failed' in output: - messages.error(request, - _('Error when configuring XMPP server: %s') % - output) - else: - messages.success(request, _('LDAP authentication disabled')) - if not old_status['inband_enabled'] and new_status['inband_enabled']: setting_changed = True output = actions.superuser_run('xmpp', ['enable-inband'])