blob: 8847f35034f1765845528ec62a948a42ef41bc95 [file] [log] [blame]
Iftekharul Islamcd789502017-04-19 14:37:55 -05001/**
2 * Controller for user Accounts
3 *
4 * @module app/users
5 * @exports userAccountsController
6 * @name userAccountsController
7 * @version 0.1.0
8 */
9
10window.angular && (function (angular) {
11 'use strict';
12
13 angular
14 .module('app.users')
15 .controller('userAccountsController', [
Gunnar Millseedefd32018-02-28 17:02:34 -060016 '$scope',
17 '$window',
18 'APIUtils',
Iftekharul Islamcd789502017-04-19 14:37:55 -050019 'dataService',
20 function($scope, $window, APIUtils, dataService){
21 $scope.dataService = dataService;
Gunnar Mills6b97dde2018-03-14 17:04:58 -050022 $scope.changePassword = function(oldPassword, newPassword, confirmNewPassword){
23 if(!oldPassword || !newPassword || !confirmNewPassword ){
24 // TODO: Display error
25 return false;
26 }
27 if (newPassword !== confirmNewPassword){
28 // TODO: Display error
29 return false;
30 }
31 if (newPassword === oldPassword){
32 // TODO: Display error
33 return false;
34 }
35 // TODO: Verify the oldPassword is correct
36
37 APIUtils.changePassword($scope.dataService.getUser(), newPassword).then(function(response){
38 // Clear the textboxes on a success
39 $scope.passwordVerify = '';
40 $scope.password = '';
41 $scope.oldPassword = '';
42 }, function(error){
43 // TODO: Display error
44 });
45 }
Iftekharul Islamcd789502017-04-19 14:37:55 -050046 }
47 ]
48 );
Iftekharul Islamcd789502017-04-19 14:37:55 -050049})(angular);