Only show change password form when a password change is possible (#26779)

* only show change password form when a password change is possible

* cleanup

* remove test code

* improved message
This commit is contained in:
Larry Gregory 2018-12-11 07:35:31 -05:00 committed by GitHub
parent 92a8b49f3d
commit f401d031b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View file

@ -6,3 +6,4 @@
export const GLOBAL_RESOURCE = '*';
export const IGNORED_TYPES = ['space'];
export const REALMS_ELIGIBLE_FOR_PASSWORD_CHANGE = ['reserved', 'native'];

View file

@ -52,7 +52,14 @@
</div>
<!-- Change password -->
<div class="kuiFormSection" ng-if="!showChangePassword">
<label class="kuiFormLabel" i18n-id="xpack.security.account.passwordLabel" i18n-default-message="Password"></label>
<div class="euiText">
<p i18n-id="xpack.security.account.changePasswordNotSupportedText" i18n-default-message="You cannot change the password for this account."></p>
</div>
</div>
<kbn-change-password-form
ng-if="showChangePassword"
require-current-password="true"
show-kibana-warning="user.metadata._reserved && user.username === 'kibana'"
on-change-password="saveNewPassword(newPassword, currentPassword, onSuccess, onIncorrectPassword)"

View file

@ -11,6 +11,7 @@ import template from './account.html';
import '../management/change_password_form/change_password_form';
import '../../services/shield_user';
import { i18n } from '@kbn/i18n';
import { REALMS_ELIGIBLE_FOR_PASSWORD_CHANGE } from '../../../common/constants';
routes.when('/account', {
template,
@ -33,6 +34,9 @@ routes.when('/account', {
const notifier = new Notifier();
const { authentication_realm: authenticationRealm } = $scope.user;
$scope.showChangePassword = REALMS_ELIGIBLE_FOR_PASSWORD_CHANGE.includes(authenticationRealm.type);
$scope.saveNewPassword = (newPassword, currentPassword, onSuccess, onIncorrectPassword) => {
$scope.user.newPassword = newPassword;
if (currentPassword) {