Files
roboto-promoto/app/scripts/controllers/settings.js
2014-03-21 22:04:25 +00:00

22 lines
589 B
JavaScript

'use strict';
angular.module('robotoPromotoApp')
.controller('SettingsCtrl', function ($scope, User, Auth) {
$scope.errors = {};
$scope.changePassword = function(form) {
$scope.submitted = true;
if(form.$valid) {
Auth.changePassword( $scope.user.oldPassword, $scope.user.newPassword )
.then( function() {
$scope.message = 'Password successfully changed.';
})
.catch( function() {
form.password.$setValidity('mongoose', false);
$scope.errors.other = 'Incorrect password';
});
}
};
});