mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-16 12:22:26 +01:00
29 lines
945 B
JavaScript
29 lines
945 B
JavaScript
'use strict';
|
|
|
|
angular.module('users').controller('ChangePasswordController', ['$scope', '$http', 'Authentication', 'PasswordValidator',
|
|
function ($scope, $http, Authentication, PasswordValidator) {
|
|
$scope.user = Authentication.user;
|
|
$scope.popoverMsg = PasswordValidator.getPopoverMsg();
|
|
|
|
// Change user password
|
|
$scope.changeUserPassword = function (isValid) {
|
|
$scope.success = $scope.error = null;
|
|
|
|
if (!isValid) {
|
|
$scope.$broadcast('show-errors-check-validity', 'passwordForm');
|
|
|
|
return false;
|
|
}
|
|
|
|
$http.post('/api/users/password', $scope.passwordDetails).success(function (response) {
|
|
// If successful show success message and clear form
|
|
$scope.$broadcast('show-errors-reset', 'passwordForm');
|
|
$scope.success = true;
|
|
$scope.passwordDetails = null;
|
|
}).error(function (response) {
|
|
$scope.error = response.message;
|
|
});
|
|
};
|
|
}
|
|
]);
|