From 93dc2d569dad23a2d04523b2281af347ab93799c Mon Sep 17 00:00:00 2001 From: Serhii Tsymbaliuk Date: Thu, 27 Jun 2019 12:51:33 +0200 Subject: [PATCH] WebUI: Disable 'Unlock' action for users with no password Administrator should reset user password to make the unlock option available. Ticket: https://pagure.io/freeipa/issue/5062 Signed-off-by: Serhii Tsymbaliuk Reviewed-By: Alexander Bokovoy --- install/ui/src/freeipa/user.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js index ecd064211..cd042b43a 100644 --- a/install/ui/src/freeipa/user.js +++ b/install/ui/src/freeipa/user.js @@ -407,6 +407,7 @@ return { label: '@i18n:objects.user.unlock', needs_confirm: true, hide_cond: ['preserved-user'], + disable_cond: ['no-password'], confirm_msg: '@i18n:objects.user.unlock_confirm' }, { @@ -442,6 +443,7 @@ return { }, IPA.user.self_service_other_user_evaluator, IPA.user.preserved_user_evaluator, + IPA.user.no_password_evaluator, IPA.cert.certificate_evaluator ], summary_conditions: [ @@ -1078,6 +1080,35 @@ IPA.user.deleter_dialog = function(spec) { return that; }; +IPA.user.no_password_evaluator = function(spec) { + + spec = spec || {}; + spec.event = spec.event || 'post_load'; + + var that = IPA.state_evaluator(spec); + that.name = spec.name || 'no_password_evaluator'; + that.param = spec.param || 'has_password'; + that.adapter = builder.build('adapter', { $type: 'adapter'}, { context: that }); + + /** + * Evaluates if user has no password + */ + that.on_event = function(data) { + + var old_state = that.state; + that.state = []; + + var has_password = that.adapter.load(data)[0]; + if (!has_password) { + that.state.push('no-password'); + } + + that.notify_on_change(old_state); + }; + + return that; +}; + exp.entity_spec = make_spec(); exp.register = function() { var e = reg.entity;