From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 428921FF17A for ; Tue, 28 Oct 2025 13:50:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B1E3F1A6CA; Tue, 28 Oct 2025 13:50:48 +0100 (CET) Mime-Version: 1.0 Date: Tue, 28 Oct 2025 13:50:15 +0100 Message-Id: From: "Shan Shaji" To: "Shannon Sterz" X-Mailer: aerc 0.20.0 References: <20251028121918.271559-1-s.shaji@proxmox.com> In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761655803608 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.110 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [yew-devel] [PATCH proxmox-yew-comp] fix #6787: ui: allow creating PAM users from dashboard X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Cc: Yew framework devel list at Proxmox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" On Tue Oct 28, 2025 at 1:46 PM CET, Shannon Sterz wrote: > On Tue Oct 28, 2025 at 1:19 PM CET, Shan Shaji wrote: >> When tried to create a user in the PAM realm an error occurs if the user >> doesn't exist on the host. To fix the issue hid the password and confirm >> password fields. Now the user will only be added to the `.cfg` file and >> won't be trying to update the password. The error was originating from >> the invocation of `pam_chauthtok`. >> >> Since the user is not created on the system, if tried to change the >> password the same error will be shown again. Inorder to avoid that >> the "change password" button will only be enabled if the user is >> not a "pam" user. >> >> Signed-off-by: Shan Shaji >> --- >> src/user_panel.rs | 63 ++++++++++++++++++++++++++++++----------------- >> 1 file changed, 41 insertions(+), 22 deletions(-) >> >> diff --git a/src/user_panel.rs b/src/user_panel.rs >> index d983928..fec9b2c 100644 >> --- a/src/user_panel.rs >> +++ b/src/user_panel.rs >> @@ -165,8 +165,12 @@ impl LoadableComponent for ProxmoxUserPanel { >> >> fn toolbar(&self, ctx: &LoadableComponentContext) -> Option { >> let link = ctx.link(); >> - >> let disabled = self.selection.is_empty(); >> + let mut disable_change_password = disabled; >> + >> + if let Some(user) = self.get_selected_user() { >> + disable_change_password = user.user.userid.realm().as_str() == "pam"; >> + } >> >> let toolbar = Toolbar::new() >> .class("pwt-w-100") >> @@ -190,7 +194,7 @@ impl LoadableComponent for ProxmoxUserPanel { >> .with_spacer() >> .with_child( >> Button::new(tr!("Change Password")) >> - .disabled(disabled) >> + .disabled(disable_change_password) >> .onclick(link.change_view_callback(|_| Some(ViewState::ChangePassword))), >> ) >> .with_child( >> @@ -257,6 +261,13 @@ fn check_confirm_password(form_ctx: FormContext) { >> } >> >> impl ProxmoxUserPanel { >> + fn get_selected_user(&self) -> Option { >> + self.selection >> + .selected_key() >> + .map(|key| self.store.read().lookup_record(&key).cloned()) >> + .flatten() > > could you use an `and_then` instead of the `map` above and safe on the > flatten here? Yes, will send an updated patch. Thank you! >> + } >> + >> fn create_add_dialog(&self, ctx: &LoadableComponentContext) -> Html { >> EditWindow::new(tr!("Add") + ": " + &tr!("User")) >> .renderer(add_user_input_panel) >> @@ -463,8 +474,10 @@ fn password_change_input_panel(_form_ctx: &FormContext) -> Html { >> .into() >> } >> >> -fn add_user_input_panel(_form_ctx: &FormContext) -> Html { >> - InputPanel::new() >> +fn add_user_input_panel(form_ctx: &FormContext) -> Html { >> + let is_pam = form_ctx.read().get_field_text("realm") == "pam"; >> + >> + let mut panel = InputPanel::new() >> .padding(4) >> .with_field( >> tr!("User name"), >> @@ -481,24 +494,30 @@ fn add_user_input_panel(_form_ctx: &FormContext) -> Html { >> .name("realm") >> .required(true) >> .submit(false), >> - ) >> - .with_field( >> - tr!("Password"), >> - Field::new() >> - .name("password") >> - .required(true) >> - .schema(&PASSWORD_SCHEMA) >> - .input_type(InputType::Password), >> - ) >> - // fixme: validate confirmation >> - .with_field( >> - tr!("Confirm password"), >> - Field::new() >> - .name("confirm_password") >> - .required(true) >> - .submit(false) >> - .input_type(InputType::Password), >> - ) >> + ); >> + >> + if !is_pam { >> + panel = panel >> + .with_field( >> + tr!("Password"), >> + Field::new() >> + .name("password") >> + .required(true) >> + .schema(&PASSWORD_SCHEMA) >> + .input_type(InputType::Password), >> + ) >> + // fixme: validate confirmation >> + .with_field( >> + tr!("Confirm password"), >> + Field::new() >> + .name("confirm_password") >> + .required(true) >> + .submit(false) >> + .input_type(InputType::Password), >> + ); >> + } >> + >> + panel >> .with_field( >> tr!("Expire"), >> Field::new() _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel