all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [yew-devel] [PATCH proxmox-yew-comp v2] fix #6787: ui: allow creating PAM users from dashboard
@ 2025-10-28 13:33 Shan Shaji
  2025-11-06 20:42 ` [yew-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Shan Shaji @ 2025-10-28 13:33 UTC (permalink / raw)
  To: yew-devel

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 <s.shaji@proxmox.com>
---
 changes since v1: Thanks @Shannon
 - Use `and_then` combinator instead of chaining `map` and `flatten`
   functions.

 src/user_panel.rs | 62 ++++++++++++++++++++++++++++++-----------------
 1 file changed, 40 insertions(+), 22 deletions(-)

diff --git a/src/user_panel.rs b/src/user_panel.rs
index d983928..1488a66 100644
--- a/src/user_panel.rs
+++ b/src/user_panel.rs
@@ -165,8 +165,12 @@ impl LoadableComponent for ProxmoxUserPanel {
 
     fn toolbar(&self, ctx: &LoadableComponentContext<Self>) -> Option<Html> {
         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,12 @@ fn check_confirm_password(form_ctx: FormContext) {
 }
 
 impl ProxmoxUserPanel {
+    fn get_selected_user(&self) -> Option<UserWithTokens> {
+        self.selection
+            .selected_key()
+            .and_then(|key| self.store.read().lookup_record(&key).cloned())
+    }
+
     fn create_add_dialog(&self, ctx: &LoadableComponentContext<Self>) -> Html {
         EditWindow::new(tr!("Add") + ": " + &tr!("User"))
             .renderer(add_user_input_panel)
@@ -463,8 +473,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 +493,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()
-- 
2.47.3



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [yew-devel] applied: [PATCH proxmox-yew-comp v2] fix #6787: ui: allow creating PAM users from dashboard
  2025-10-28 13:33 [yew-devel] [PATCH proxmox-yew-comp v2] fix #6787: ui: allow creating PAM users from dashboard Shan Shaji
@ 2025-11-06 20:42 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2025-11-06 20:42 UTC (permalink / raw)
  To: yew-devel, Shan Shaji

On Tue, 28 Oct 2025 14:33:26 +0100, 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.
> 
> [...]

Applied, with a small code clean-up on top, thanks!

[1/1] fix #6787: ui: allow creating PAM users from dashboard
      commit: bbad5fd1856984aefa82a24114827e6bc025e8f0


_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-06 20:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-28 13:33 [yew-devel] [PATCH proxmox-yew-comp v2] fix #6787: ui: allow creating PAM users from dashboard Shan Shaji
2025-11-06 20:42 ` [yew-devel] applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal