diff --git a/management/univention-management-console/www/management/main.js b/management/univention-management-console/www/management/main.js index e66f566850..54980c6403 100644 --- a/management/univention-management-console/www/management/main.js +++ b/management/univention-management-console/www/management/main.js @@ -82,6 +82,8 @@ define([ "umc/widgets/GalleryPane", "umc/widgets/ContainerWidget", "umc/widgets/Page", + "umc/widgets/PasswordBox", + "umc/widgets/PasswordInputBox", "umc/widgets/Form", "umc/widgets/Button", "umc/widgets/Text", @@ -91,7 +93,7 @@ define([ Evented, Deferred, all, cookie, topic, ioQuery, Memory, Observable, dom, domAttr, domClass, domGeometry, domConstruct, style, put, hash, styles, entities, gfx, registry, tools, login, dialog, NotificationDropDownButton, NotificationSnackbar, store, _WidgetBase, Menu, MenuItem, PopupMenuItem, MenuSeparator, Tooltip, DropDownButton, StackContainer, menu, MenuButton, - TabController, LiveSearch, GalleryPane, ContainerWidget, Page, Form, Button, Text, _ + TabController, LiveSearch, GalleryPane, ContainerWidget, Page, PasswordBox, PasswordInputBox, Form, Button, Text, _ ) { // cache UCR variables var _favoritesDisabled = false; @@ -1075,7 +1077,7 @@ define([ } if (!launchableModules.length) { - dialog.alert(_('There is no module available for the authenticated user %s.', tools.status('username'))); + this._showPasswordChangeDialog(); } else if (launchableModules.length === 1) { // if only one module exists open it var module = launchableModules[0]; @@ -1085,7 +1087,6 @@ define([ this.openModule(autoStartModule, autoStartFlavor, props); } }, - setupGui: function() { // make sure that we have not build the GUI before if (tools.status('setupGui')) { @@ -1099,12 +1100,71 @@ define([ this._header.setupGui(); this._setupOverviewPage(); this._setupStateHashing(); + this._setupPasswordMenu(); // set a flag that GUI has been build up tools.status('setupGui', true); this.onGuiDone(); }, + _showPasswordChangeDialog: function() { + var setPassword = function(values) { + tools.umcpCommand('set', { + password: values + }, false).then(lang.hitch(this, function() { + dialog.alert(_('The password has been changed successfully.')); + }), lang.hitch(this, function(err) { + err = tools.parseError(err); + dialog.confirm(err.message, [{ + label: _('OK'), + 'default': true + }], _('Error changing password')).then(showPasswordChangeDialog); + })); + }; + menu.close(); + dialog.confirmForm({ + widgets: [{ + type: Text, + name: 'text', + content: _('Change the password of user "%s":', tools.status('username')) + }, { + name: 'password', + type: PasswordBox, + label: _('Old password') + }, { + name: 'new_password', + type: PasswordInputBox, + twoRows: true, + label: _('New password') + }], + title: _('Change password'), + submit: _('Change password'), + }).then(setPassword, function() {}); + }, + + _setupPasswordMenu: function() { + var entry = menu.addEntry({ + id: 'umcMenuChangePassword', + parentMenuId: 'umcMenuUserSettings', + label: _('Change password'), + onClick: function() { + topic.publish('/umc/actions', 'menu', 'passwordchange'); + this._showPasswordChangeDialog(); + } + }); + menu.hideEntry(entry); + + login.onLogin(function() { + // user has logged in -> show menu entry + menu.showEntry(entry); + }); + + login.onLogout(function() { + // user has logged out -> hide menu entry + menu.hideEntry(entry); + }); + }, + // return the index for the given module tab, i.e., the index regarding other // open tabs if the same module ID and flavor _getModuleTabIndex: function(tab) {