TwoToc code
[YouAndWeb_TwoToc] / client / app / account / settings / settings.controller.js
1 'use strict';
2
3 angular.module('dashboardApp')
4   .controller('SettingsCtrl', function($scope, User, Auth) {
5     $scope.errors = {};
6
7     $scope.changePassword = function(form) {
8       $scope.submitted = true;
9       if (form.$valid) {
10         Auth.changePassword($scope.user.oldPassword, $scope.user.newPassword)
11           .then(function() {
12             $scope.message = 'Password successfully changed.';
13           })
14           .catch(function() {
15             form.password.$setValidity('mongoose', false);
16             $scope.errors.other = 'Incorrect password';
17             $scope.message = '';
18           });
19       }
20     };
21   });