public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Shan Shaji" <s.shaji@proxmox.com>
To: "Shannon Sterz" <s.sterz@proxmox.com>
Cc: Yew framework devel list at Proxmox <yew-devel@lists.proxmox.com>
Subject: Re: [yew-devel] [PATCH proxmox-yew-comp] fix #6787: ui: allow creating PAM users from dashboard
Date: Tue, 28 Oct 2025 13:50:15 +0100	[thread overview]
Message-ID: <DDTYV984V56D.PGO8MBTX3S3F@proxmox.com> (raw)
In-Reply-To: <DDTYS86T8N61.XVP23Y0FFS2H@proxmox.com>

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 <s.shaji@proxmox.com>
>> ---
>>  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<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,13 @@ fn check_confirm_password(form_ctx: FormContext) {
>>  }
>>
>>  impl ProxmoxUserPanel {
>> +    fn get_selected_user(&self) -> Option<UserWithTokens> {
>> +        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<Self>) -> 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


  reply	other threads:[~2025-10-28 12:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-28 12:19 Shan Shaji
2025-10-28 12:46 ` Shannon Sterz
2025-10-28 12:50   ` Shan Shaji [this message]
2025-10-28 13:34   ` Shan Shaji

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DDTYV984V56D.PGO8MBTX3S3F@proxmox.com \
    --to=s.shaji@proxmox.com \
    --cc=s.sterz@proxmox.com \
    --cc=yew-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal