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>
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 @@
'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 @@
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;
+ }
+}