(feat) added password change support
parent
d21715d8f1
commit
7168779684
|
@ -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.
|
||||
|
|
|
@ -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">
|
||||
|
||||
<main class="view md-layout-fill" ui-view="preferences" layout="row"
|
||||
ng-controller="navController"><!-- preferences --> </main>
|
||||
|
@ -212,16 +212,16 @@
|
|||
<md-input-container>
|
||||
<label><var:string label:value="New password:"/>
|
||||
</label>
|
||||
<input type="text"/>
|
||||
<input type="password" ng-model="passwords.newPassword"/>
|
||||
</md-input-container>
|
||||
|
||||
<md-input-container>
|
||||
<label><var:string label:value="Confirmation:"/>
|
||||
</label>
|
||||
<input type="text"/>
|
||||
<input type="password" ng-model="passwords.newPasswordConfirmation"/>
|
||||
</md-input-container>
|
||||
|
||||
<md-button ng-click="changePassword()" type="button">
|
||||
|
||||
<md-button ng-click="changePassword()" type="button" ng-disabled="!canChangePassword()">
|
||||
<var:string label:value="Change"/>
|
||||
</md-button>
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
});
|
||||
};
|
||||
}]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue