Skip to content

Fix saving passwords changed without a keydown event - #3347

Merged
MichaIng merged 1 commit into
motioneye-project:devfrom
Marijn0:fix-password-change-without-keydown
Jun 6, 2026
Merged

MichaIng merged 1 commit into
motioneye-project:devfrom
Marijn0:fix-password-change-without-keydown

Conversation

@Marijn0

@Marijn0 Marijn0 commented Jun 6, 2026

Copy link
Copy Markdown
Member

Fix passwords not being sent to the backend when changed without a keydown event.

This fixes an issue where passwords entered through a password manager, browser autofill, or right-click paste could appear to be accepted in the UI but were not actually saved after clicking Apply.

Those input methods can trigger a change event without triggering keydown. The frontend previously required both events before including password fields in the config payload, so the Apply request could be sent without the updated passwords.

Issue: #3345

@Marijn0 Marijn0 self-assigned this Jun 6, 2026
@Marijn0 Marijn0 linked an issue Jun 6, 2026 that may be closed by this pull request
@Marijn0 Marijn0 added the bug label Jun 6, 2026
@Marijn0 Marijn0 added this to the v0.44.0 milestone Jun 6, 2026
@Marijn0
Marijn0 requested a review from MichaIng June 6, 2026 12:56
@MichaIng

MichaIng commented Jun 6, 2026 •

Copy link
Copy Markdown
Member

I do not understand either why the keydown event was an additional condition.

Actually, if we pre-fill the fields with *****, we do not even need to track the "change" event, but take the value as only condition. The latter implies the first, hence the first is redundant, if I am not missing something.

@Marijn0

Marijn0 commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

Actually, if we pre-fill the fields with *****, we do not even need to track the "change" event, but take the value as only condition. The latter implies the first, hence the first is redundant, if I am not missing something.

Good point, so we can just use something like:

if ($('#adminPasswordEntry').val() !== '*****') {

which is much cleaner.

I am not sure why all those conditions were needed in the past. Maybe they were there to avoid submitting empty password fields. But now that the admin and surveillance user passwords are required, those extra conditions can be removed AFAICS.

@MichaIng

MichaIng commented Jun 6, 2026 •

Copy link
Copy Markdown
Member

Even a change + keydown event does not assure the field is not empty. I mean making it empty requires a change and a keydown (assuming no password manager can enter an empty password).

Maybe the conditions were incrementally appended ... yeah, see here: 818cd28

So the keydown condition was explicitly added to prevent saving autofilled password, not considering password managers, but browser autocompletion features which sometimes touch all input fields without actually changing the content.

The failsafe "addition" of checking ***** however made the other unreliable conditions obsolete.

This also explains why there was/is another ***** check in the backend. I guess this was added when it was not present in the frontend yet. Now that it is, the backend does not need to filter this anymore.

Password fields are pre-filled with ***** when unchanged, so the frontend can use that placeholder as the condition for whether to send a password value.
This avoids relying on keydown/change tracking, which can miss values entered by password managers, autofill, or context-menu paste.
@Marijn0
Marijn0 force-pushed the fix-password-change-without-keydown branch from bd9732c to 13012b5 Compare June 6, 2026 15:16
@Marijn0

Marijn0 commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

Good find!

This also explains why there was/is another ***** check in the backend. I guess this was added when it was not present in the frontend yet. Now that it is, the backend does not need to filter this anymore.

If there are still any such checks in the backend, could you please point me to them?

@MichaIng MichaIng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great when a bug can be fixed by removing and simplifying code 👍🙂

@MichaIng
MichaIng merged commit 2482a43 into motioneye-project:dev Jun 6, 2026
17 of 18 checks passed
@Marijn0
Marijn0 deleted the fix-password-change-without-keydown branch June 6, 2026 20:15
@MichaIng

MichaIng commented Jun 6, 2026

Copy link
Copy Markdown
Member

If there are still any such checks in the backend, could you please point me to them?

It is not there anymore. I just remember this popped up in a PR, maybe got removed, or maybe someone wanted to add it in the backend. I just remember that I verified the frontend does the ***** filtering already, and that hence it wouldn't be needed in the backend.

This was referenced Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Pi Zero 2W Trixie 64-bit - not remembering entered passwords

2 participants