UNPKG

generator-ngfs

Version:

Yeoman generator for creating MEAN stack applications, using MongoDB, Express, AngularJS, and Node

22 lines (18 loc) 593 B
'use strict'; angular.module('<%= scriptAppName %>') .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'; }); } }; });