dubdiff/client/app/account/settings/settings.controller.js

22 lines
625 B
JavaScript

'use strict';
angular.module('markdownFormatWdiffApp')
.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';
$scope.message = '';
});
}
};
});