Identity Pro Blazor: never submit the users page's forms natively #23232
BackVolobox task: VolosoftWorkspace#1933
Problem
On the Blazorise users page, Save in New user clicked shortly after the dialog appears submits the dialog's form natively, as a GET to the current page. The ABP 11.0.0-rc.2 smoke test caught it on a Blazor Web App (app-webapp-sqlite), where the dialog took 7.5 s to appear on a busy server:
[INF] Request starting HTTP/2 GET https://localhost:44341/identity/users?NewEntity.UserName=smoke-lock-mwevhrujolx&NewEntity.Name=Smoke&NewEntity.Surname=Feature&NewEntity.Password=<clear text>&NewEntity.Email=…
As a result:
- the password is in the URL, in the browser history, and in clear text in the server's request log;
- the page reloads and the user is not created.
Cause
- The Blazorise
<Form id="CreateUserForm">renders a plain<form id="CreateUserForm">without amethod, so a native submit is a GET. A recorded trace shows exactly<form id="CreateRoleForm">for the roles page. - ABP's
SubmitButtonrelies on Blazorise'sPreventDefaultOnSubmit. Blazorise 2.3.0 implements it inbutton.jsinitialize(), which adds thepreventDefaultclick listener only after that module has been imported and initialised, after the first render. - A click or Enter before that is a real form submission.
Change
On the users page (UserManagement.razor) and in its external-user import dropdown, which also has a password field (IdentityUserImportDropdownComponent.razor), every Blazorise <Form> becomes a native <form> with the same id and @onsubmit:preventDefault.
Blazor applies preventDefault in the same render that adds the form to the page. A native submit is therefore blocked from the start, whatever the state of Blazorise's scripts. The rendered markup is otherwise the same, since Blazorise's Form adds no class or method. SubmitButton's Clicked handlers are unchanged, so Save and Enter still save.
The impersonation form (method="post" action="Account/ImpersonateUser", submitted from code) is not touched.
How it was checked
Volo.Abp.Identity.Pro.Blazorbuilds (0 errors).- Not run in a solution yet. The race needs Save before Blazorise's
button.jsis initialised. To try it, throttle the network or CPU in the browser's dev tools, or block_content/Blazorise/button.js. Then save a new user: the URL must not change, and the user must be created.
Not in this PR
The same pattern (a Blazorise <Form> plus SubmitButton) is in every Blazorise create/edit modal; 51 .razor files in this repository use SubmitButton. Forms with secrets are the next candidates, for example SaaS's new tenant (admin password). A framework-level fix in ABP's SubmitButton or in Blazorise would cover them all. This PR fixes the users page that was reported.
🤖 Generated with Claude Code