diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m
index c76e19d76..3001e7cd6 100644
--- a/UI/MainUI/SOGoRootPage.m
+++ b/UI/MainUI/SOGoRootPage.m
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2006-2014 Inverse inc.
+ Copyright (C) 2006-2015 Inverse inc.
Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of SOGo.
diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox
index 76db2043e..52f65ea41 100644
--- a/UI/Templates/PreferencesUI/UIxPreferences.wox
+++ b/UI/Templates/PreferencesUI/UIxPreferences.wox
@@ -9,7 +9,7 @@
xmlns:label="OGo:label"
className="UIxPageFrame"
title="title"
- const:jsFiles="Common/resource.js,Mailer/mailbox-model.js,Mailer/message-model.js,Preferences/preferences-model.js">
+ const:jsFiles="Common/resource.js,Common/SOGoAuthentication.js,Mailer/mailbox-model.js,Mailer/message-model.js,Preferences/preferences-model.js">
@@ -212,16 +212,16 @@
-
+
-
+
-
-
+
+
diff --git a/UI/WebServerResources/js/Common/SOGoAuthentication.js b/UI/WebServerResources/js/Common/SOGoAuthentication.js
index f8cd9e742..f280aa9cf 100644
--- a/UI/WebServerResources/js/Common/SOGoAuthentication.js
+++ b/UI/WebServerResources/js/Common/SOGoAuthentication.js
@@ -167,6 +167,49 @@
d.reject({error: msg});
});
return d.promise;
+ }, // login: function(data) { ...
+
+ changePassword: function(newPassword) {
+ var d = $q.defer(),
+ loginCookie = _this.readLoginCookie();
+
+ $http({
+ method: 'POST',
+ url: '/SOGo/so/changePassword',
+ data: {
+ userName: loginCookie[0],
+ password: loginCookie[1],
+ newPassword: newPassword }
+ }).success(function(data, status) {
+ d.resolve();
+ }).error(function(data, status) {
+ var error,
+ perr = data["LDAPPasswordPolicyError"];
+
+ if (!perr) {
+ perr = passwordPolicyConfig.PolicyPasswordSystemUnknown;
+ error = _("Unhandled error response");
+ }
+ else if (perr == passwordPolicyConfig.PolicyNoError) {
+ error = l("Password change failed");
+ } else if (perr == passwordPolicyConfig.PolicyPasswordModNotAllowed) {
+ error = l("Password change failed - Permission denied");
+ } else if (perr == passwordPolicyConfig.PolicyInsufficientPasswordQuality) {
+ error = l("Password change failed - Insufficient password quality");
+ } else if (perr == passwordPolicyConfig.PolicyPasswordTooShort) {
+ error = l("Password change failed - Password is too short");
+ } else if (perr == passwordPolicyConfig.PolicyPasswordTooYoung) {
+ error = l("Password change failed - Password is too young");
+ } else if (perr == passwordPolicyConfig.PolicyPasswordInHistory) {
+ error = l("Password change failed - Password is in history");
+ } else {
+ error = l("Unhandled policy error: %{0}").formatted(perr);
+ perr = passwordPolicyConfig.PolicyPasswordUnknown;
+ }
+
+ d.reject(error);
+ });
+ return d.promise;
}
};
return service;
diff --git a/UI/WebServerResources/js/PreferencesUI.js b/UI/WebServerResources/js/PreferencesUI.js
index 7138313ed..7ef5a3aa1 100644
--- a/UI/WebServerResources/js/PreferencesUI.js
+++ b/UI/WebServerResources/js/PreferencesUI.js
@@ -7,7 +7,7 @@
angular.module('SOGo.Common', []);
angular.module('SOGo.MailerUI', []);
- angular.module('SOGo.PreferencesUI', ['ngSanitize', 'ui.router', 'SOGo.Common', 'SOGo.MailerUI', 'SOGo.UIDesktop', 'SOGo.UI'])
+ angular.module('SOGo.PreferencesUI', ['ngSanitize', 'ui.router', 'SOGo.Common', 'SOGo.MailerUI', 'SOGo.UIDesktop', 'SOGo.UI', 'SOGo.Authentication'])
.constant('sgSettings', {
baseURL: ApplicationBaseURL,
@@ -72,7 +72,7 @@
$urlRouterProvider.otherwise('/general');
}])
- .controller('PreferencesCtrl', ['$scope', '$timeout', '$mdDialog', 'sgPreferences', 'statePreferences', function($scope, $timeout, $mdDialog, Preferences, statePreferences) {
+ .controller('PreferencesCtrl', ['$scope', '$timeout', '$mdDialog', 'sgPreferences', 'statePreferences', 'Authentication', function($scope, $timeout, $mdDialog, Preferences, statePreferences, Authentication) {
$scope.preferences = statePreferences;
@@ -175,12 +175,42 @@
};
$scope.save = function() {
- console.debug("save");
$scope.preferences.$save();
};
+ $scope.passwords = { newPassword: null, newPasswordConfirmation: null };
+
+ $scope.canChangePassword = function() {
+ if ($scope.passwords.newPassword && $scope.passwords.newPassword.length > 0 &&
+ $scope.passwords.newPasswordConfirmation && $scope.passwords.newPasswordConfirmation.length &&
+ $scope.passwords.newPassword == $scope.passwords.newPasswordConfirmation)
+ return true;
+
+ return false;
+ };
+
$scope.changePassword = function() {
- console.debug("change password");
+ Authentication.changePassword($scope.passwords.newPassword).then(function() {
+ var alert = $mdDialog.alert({
+ title: l('Password'),
+ content: l('The password was changed successfully.'),
+ ok: 'OK'
+ });
+ $mdDialog.show( alert )
+ .finally(function() {
+ alert = undefined;
+ });
+ }, function(msg) {
+ var alert = $mdDialog.alert({
+ title: l('Password'),
+ content: msg,
+ ok: 'OK'
+ });
+ $mdDialog.show( alert )
+ .finally(function() {
+ alert = undefined;
+ });
+ });
};
}]);