Files
meanTorrent/modules/users/client/controllers/settings/change-password.client.controller.js
Marek Grzybek d14d5130af feat(config): Deprecate JSHint in favor of ESLint
Add basic ESLint setup extending well-known Airbnb code style.

Fixes #1072, #1097
2016-03-15 19:11:12 +01:00

38 lines
1.1 KiB
JavaScript

(function () {
'use strict';
angular
.module('users')
.controller('ChangePasswordController', ChangePasswordController);
ChangePasswordController.$inject = ['$scope', '$http', 'Authentication', 'PasswordValidator'];
function ChangePasswordController($scope, $http, Authentication, PasswordValidator) {
var vm = this;
vm.user = Authentication.user;
vm.changeUserPassword = changeUserPassword;
vm.getPopoverMsg = PasswordValidator.getPopoverMsg;
// Change user password
function changeUserPassword(isValid) {
vm.success = vm.error = null;
if (!isValid) {
$scope.$broadcast('show-errors-check-validity', 'vm.passwordForm');
return false;
}
$http.post('/api/users/password', vm.passwordDetails).success(function (response) {
// If successful show success message and clear form
$scope.$broadcast('show-errors-reset', 'vm.passwordForm');
vm.success = true;
vm.passwordDetails = null;
}).error(function (response) {
vm.error = response.message;
});
}
}
}());