diff options
author | Gunnar Mills <gmills@us.ibm.com> | 2018-03-14 17:04:58 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-03-23 19:57:11 +0000 |
commit | 6b97dde1f28199975d55682bd01b503150efe0c1 (patch) | |
tree | 2fd335cdc540270d8136695421b742f3ec16e433 | |
parent | 55a8e3916230962ef0e74a78bd805e0b015ed5b2 (diff) | |
download | phosphor-webui-6b97dde1f28199975d55682bd01b503150efe0c1.tar.gz phosphor-webui-6b97dde1f28199975d55682bd01b503150efe0c1.zip |
Call changePassword() on "Save change" press
Call the changePassword() function when a user presses the
"Save change" Change password button.
Also, validate the password fields.
Tested: Changed the password on a Witherspoon.
Change-Id: I479929c82c5e405591fa7b1cf01e5491d35079e7
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
-rw-r--r-- | app/users/controllers/user-accounts-controller.html | 6 | ||||
-rw-r--r-- | app/users/controllers/user-accounts-controller.js | 25 |
2 files changed, 27 insertions, 4 deletions
diff --git a/app/users/controllers/user-accounts-controller.html b/app/users/controllers/user-accounts-controller.html index 3f05bff..80b6c7d 100644 --- a/app/users/controllers/user-accounts-controller.html +++ b/app/users/controllers/user-accounts-controller.html @@ -11,7 +11,7 @@ <legend aria-label="user manager" class="accessible-text">Change password form</legend> <div class="row column"> <label for="user-manage__current-password">Current password</label> - <input id="user-manage__current-password" type="password" class="user-manage__current-password inline"/> + <input id="user-manage__current-password" type="password" ng-model="oldPassword" class="user-manage__current-password inline"/> </div> <div class="inline"> <label for="user-manage__new-password">New password</label> @@ -35,8 +35,8 @@ </div> </fieldset> <div class="user-manage__submit-wrapper"> - <button class="btn-primary inline">Save change</button> + <button class="btn-primary inline" ng-click="changePassword(oldPassword, password, passwordVerify)">Save change</button> </div> </form> </section> -</div>
\ No newline at end of file +</div> diff --git a/app/users/controllers/user-accounts-controller.js b/app/users/controllers/user-accounts-controller.js index f3d7160..8847f35 100644 --- a/app/users/controllers/user-accounts-controller.js +++ b/app/users/controllers/user-accounts-controller.js @@ -19,8 +19,31 @@ window.angular && (function (angular) { 'dataService', function($scope, $window, APIUtils, dataService){ $scope.dataService = dataService; + $scope.changePassword = function(oldPassword, newPassword, confirmNewPassword){ + if(!oldPassword || !newPassword || !confirmNewPassword ){ + // TODO: Display error + return false; + } + if (newPassword !== confirmNewPassword){ + // TODO: Display error + return false; + } + if (newPassword === oldPassword){ + // TODO: Display error + return false; + } + // TODO: Verify the oldPassword is correct + + APIUtils.changePassword($scope.dataService.getUser(), newPassword).then(function(response){ + // Clear the textboxes on a success + $scope.passwordVerify = ''; + $scope.password = ''; + $scope.oldPassword = ''; + }, function(error){ + // TODO: Display error + }); + } } ] ); - })(angular); |