Skip to content

Commit

Permalink
[6.x] Only show change password form when a password change is possib…
Browse files Browse the repository at this point in the history
…le (elastic#26779) (elastic#26954)

Backports the following commits to 6.x:
 - Only show change password form when a password change is possible  (elastic#26779)
  • Loading branch information
legrego authored Dec 11, 2018
1 parent 1ced518 commit 17b6fc7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/security/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

export const GLOBAL_RESOURCE = '*';
export const IGNORED_TYPES = ['space'];
export const REALMS_ELIGIBLE_FOR_PASSWORD_CHANGE = ['reserved', 'native'];
7 changes: 7 additions & 0 deletions x-pack/plugins/security/public/views/account/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/security/public/views/account/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import template from './account.html';
import '../management/change_password_form/change_password_form';
import '../../services/shield_user';
import { GateKeeperProvider } from 'plugins/xpack_main/services/gate_keeper';
import { REALMS_ELIGIBLE_FOR_PASSWORD_CHANGE } from '../../../common/constants';

routes.when('/account', {
template,
Expand All @@ -30,6 +31,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) {
Expand Down

0 comments on commit 17b6fc7

Please sign in to comment.