diff --git a/base/univention-system-activation/src/wsgi.py b/base/univention-system-activation/src/wsgi.py index 2631fcaf5a..ccc98b52d3 100644 --- a/base/univention-system-activation/src/wsgi.py +++ b/base/univention-system-activation/src/wsgi.py @@ -2,6 +2,7 @@ import cgi import subprocess +import traceback import json import re from ldif import LDIFParser @@ -69,7 +70,13 @@ def clean_license_output(out): def application(environ, start_response): - """WSGI entry point""" + def _error(message, trace=None): + return { + 'status': 500, + 'message': message, + 'traceback': trace, + 'location': '', + } def _log(msg): print >> environ['wsgi.errors'], msg @@ -91,7 +98,9 @@ def application(environ, start_response): return _finish(data=out) except subprocess.CalledProcessError as exc: _log('Failed to read license data from LDAP:\n%s' % exc) - return _finish('400 Bad Request', 'Failed to read license data from LDAP:\n%s' % exc) + return _finish('500 Internal Server Error', _error('Failed to read license data from LDAP:\n%s' % exc)) + except Exception as exc: + return _finish(data=_error(str(exc), traceback.format_exc())) # block uploads that are larger than 1MB try: diff --git a/base/univention-system-activation/www/ActivationWizard.js b/base/univention-system-activation/www/ActivationWizard.js index ebf0047862..5e7b98afbc 100644 --- a/base/univention-system-activation/www/ActivationWizard.js +++ b/base/univention-system-activation/www/ActivationWizard.js @@ -44,9 +44,8 @@ define([ "umc/widgets/Text", "umc/widgets/TextBox", "put-selector/put", - "umc/json!/license", "umc/i18n!systemactivation" -], function(declare, lang, array, Deferred, ioQuery, domQuery, request, xhr, script, Uploader, dialog, Wizard, Text, TextBox, put, license, _) { +], function(declare, lang, array, Deferred, ioQuery, domQuery, request, xhr, script, Uploader, dialog, Wizard, Text, TextBox, put, _) { return declare("ActivationWizard", [ Wizard ], { autoFocus: true, entries: null, @@ -201,16 +200,20 @@ define([ emailNode.innerHTML = email_address; // send the email - var data = { - email: email_address, - licence: license - }; - return xhr.post('https://license.univention.de/keyid/conversion/submit', { - data: data, - handleAs: 'text', - headers: { - 'X-Requested-With': null - } + xhr.get('/license', { handleAs: 'json' }).then(function(license) { + var data = { + email: email_address, + licence: license + }; + return xhr.post('https://license.univention.de/keyid/conversion/submit', { + data: data, + handleAs: 'text', + headers: { + 'X-Requested-With': null + } + }); + }, function(error) { + tools.handleErrorStatus(error); }); },