diff options
author | Gunnar Mills <gmills@us.ibm.com> | 2018-03-19 16:24:41 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-03-23 19:57:12 +0000 |
commit | 08744f89dbd6356b2d1e8bdfa5fc3c9febd638fb (patch) | |
tree | 16650a49285f13b66fbfad5cb602de3ceaadb3dd /app/users | |
parent | 32581cf487e9df5f5fce9ecbcc9edcdd0565b444 (diff) | |
download | phosphor-webui-08744f89dbd6356b2d1e8bdfa5fc3c9febd638fb.tar.gz phosphor-webui-08744f89dbd6356b2d1e8bdfa5fc3c9febd638fb.zip |
Display error and success text
When an error occurs changing the password, display the
appropriate error message. On a successful password change
also display text.
Resolves openbmc/openbmc#2741
Resolves openbmc/openbmc#2969
Tested: Made all these errors show and also changed the password
on a Witherspoon.
Change-Id: I9808df9888175de988ecb0781023424315a1ec53
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'app/users')
-rw-r--r-- | app/users/controllers/user-accounts-controller.html | 4 | ||||
-rw-r--r-- | app/users/controllers/user-accounts-controller.js | 24 | ||||
-rw-r--r-- | app/users/styles/user-accounts.scss | 22 |
3 files changed, 42 insertions, 8 deletions
diff --git a/app/users/controllers/user-accounts-controller.html b/app/users/controllers/user-accounts-controller.html index 80b6c7d..49d79a8 100644 --- a/app/users/controllers/user-accounts-controller.html +++ b/app/users/controllers/user-accounts-controller.html @@ -37,6 +37,10 @@ <div class="user-manage__submit-wrapper"> <button class="btn-primary inline" ng-click="changePassword(oldPassword, password, passwordVerify)">Save change</button> </div> + <p ng-class="'change-password__' + state" role="alert"> + {{state === 'error' ? errorMsg : ''}} + {{state === 'success' ? 'Success! User Password has been changed!' : ''}} + </p> </form> </section> </div> diff --git a/app/users/controllers/user-accounts-controller.js b/app/users/controllers/user-accounts-controller.js index 355ca37..3420eaf 100644 --- a/app/users/controllers/user-accounts-controller.js +++ b/app/users/controllers/user-accounts-controller.js @@ -19,32 +19,42 @@ window.angular && (function (angular) { 'dataService', function($scope, $window, APIUtils, dataService){ $scope.dataService = dataService; + $scope.state = "none"; + $scope.errorMsg = ""; + $scope.changePassword = function(oldPassword, newPassword, confirmNewPassword){ + var user = $scope.dataService.getUser(); if(!oldPassword || !newPassword || !confirmNewPassword ){ - // TODO: Display error + $scope.state = "error"; + $scope.errorMsg = "Field is required!"; return false; } if (newPassword !== confirmNewPassword){ - // TODO: Display error + $scope.state = "error"; + $scope.errorMsg = "New passwords do not match!"; return false; } if (newPassword === oldPassword){ - // TODO: Display error + $scope.state = "error"; + $scope.errorMsg = "New password and old password match!"; return false; } // Verify the oldPassword is correct - APIUtils.testPassword($scope.dataService.getUser(), oldPassword).then(function(state){ - APIUtils.changePassword($scope.dataService.getUser(), newPassword).then(function(response){ + APIUtils.testPassword(user, oldPassword).then(function(state){ + APIUtils.changePassword(user, newPassword).then(function(response){ // Clear the textboxes on a success $scope.passwordVerify = ''; $scope.password = ''; $scope.oldPassword = ''; + $scope.state = "success"; }, function(error){ - // TODO: Display error + $scope.state = "error"; + $scope.errorMsg = "Error changing password!"; }); }, function(error){ - // TODO: Display error + $scope.state = "error"; + $scope.errorMsg = "Old password is not correct!"; }); } } diff --git a/app/users/styles/user-accounts.scss b/app/users/styles/user-accounts.scss index 28af84a..914388a 100644 --- a/app/users/styles/user-accounts.scss +++ b/app/users/styles/user-accounts.scss @@ -37,4 +37,24 @@ $userInputHeight: 40px; float: right; margin-left: .5em; } -}
\ No newline at end of file + .change-password__error + { + background: lighten($error-color, 20%); + padding: 1em; + text-align: center; + font-size: 1em; + border: 1px solid $error-color; + color: $black; + font-family: "Courier New", Helvetica, Arial, sans-serif; + font-weight: 700; + width: 325px; + } + .change-password__success + { + color: $primebtn__bg; + padding: 1em; + font-size: 1em; + font-family: "Courier New", Helvetica, Arial, sans-serif; + font-weight: 500; + } +} |