Show error messages from xmpp-setup and xmpp-register.

Avoid causing plinth to show error page.
This commit is contained in:
James Valleroy 2014-11-15 15:47:44 -05:00 committed by Sunil Mohan Adapa
parent 9d6e17660d
commit ac0f0c9eba
3 changed files with 12 additions and 5 deletions

View File

@ -16,4 +16,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
ejabberdctl register "$1" `hostname` "$2" ejabberdctl register "$1" `hostname` "$2" || echo "Failed to register XMPP account."

View File

@ -58,5 +58,5 @@ if [ "$xmpp_inband_enable" != "$xmpp_inband_enable_cur" ] ; then
else else
sed -i s/"ip_access: all"/"ip_access: trusted_network"/ /etc/ejabberd/ejabberd.yml sed -i s/"ip_access: all"/"ip_access: trusted_network"/ /etc/ejabberd/ejabberd.yml
fi fi
ejabberdctl restart ejabberdctl restart || echo "Failed to restart ejabberd with new configuration."
fi fi

View File

@ -127,14 +127,21 @@ def _apply_changes(request, old_status, new_status):
return return
if new_status['inband_enabled']: if new_status['inband_enabled']:
messages.success(request, _('Inband registration enabled'))
option = 'inband_enable' option = 'inband_enable'
else: else:
messages.success(request, _('Inband registration disabled'))
option = 'noinband_enable' option = 'noinband_enable'
LOGGER.info('Option - %s', option) LOGGER.info('Option - %s', option)
actions.superuser_run('xmpp-setup', [option]) output = actions.superuser_run('xmpp-setup', [option])
if 'Failed' in output:
messages.error(request,
_('Error when configuring XMPP server: %s') %
output)
elif option == 'inband_enable':
messages.success(request, _('Inband registration enabled'))
else:
messages.success(request, _('Inband registration disabled'))
class RegisterForm(forms.Form): # pylint: disable-msg=W0232 class RegisterForm(forms.Form): # pylint: disable-msg=W0232