Repository navigation
fix: prevent app token from being generated more than once - #3541
Merged
Merged
Conversation
Creating an app token is not idempotent: every request to POST /auth-app/tokens mints a new one. The confirm button was only disabled based on form validity, so it stayed enabled for the whole round-trip and a second click sent a second request. Only the last response was ever displayed, leaving the first token alive on the server with its secret never shown to the user. Track an in-flight `isCreating` ref, fold it into the existing `isConfirmDisabled` guard and reset it in a `finally` block. The ref is set before awaiting, so the guard also covers clicks that land before the re-render disables the button - disabling alone would leave a window open. The button shows a spinner while the request is in flight, matching InviteCollaboratorForm and OcModal.
createAppToken swallowed failures into console.error, leaving the form untouched with no explanation - the modal looked like the click simply had no effect, and the user had no way to tell a rejected request from a missed one. Show an error message on failure, matching how AppTokens already reports deletion errors, and keep the form usable so the request can be retried.
The ScienceMesh invite flow had the same double-request bug as the app token modal: generateToken was reachable both from the modal confirm button and from the inner form's submit handler, neither of which was guarded while a request was in flight. Generating an invite token mints a new one per request, so a double click or a click plus an Enter press produced two tokens. Track an in-flight ref, fold it into the existing validation guard and reset it in the finally block, then bind it to the modal so the confirm button is disabled and shows a spinner while generating. OcModal delays its spinner, so short requests do not flash. Adds the package's first unit tests, which requires declaring web-test-helpers as a dev dependency.
…eated The create modal is dispatched with hidden actions, so the only ways out are the confirm button and the modal's cancel button. The confirm button was guarded against repeated clicks, but the cancel button was not: it is disabled via the modal's isLoading flag, which nothing set while creating a token, and OcModal cancels on Escape regardless of isLoading. Cancelling mid-request unmounts the component, the request still completes, and the resulting token is never displayed - the same orphaned credential the click guard was meant to prevent, reachable with a single keypress. Pressing Escape was arguably the likeliest way to hit it. Mark the modal as loading around the request, which disables the cancel button, and block Escape in OcModal while loading to match the button it sits next to. updateModal now bails out when the modal has already been removed, since an async handler can outlive its modal.
JammingBen
requested changes
Oct 5, 2026
JammingBen
left a comment
Member
There was a problem hiding this comment.
Thanks, looks mostly good, only a few nitpicks from my side.
Co-authored-by: Jannik Stehle <[email protected]>
Co-authored-by: Jannik Stehle <[email protected]>
Co-authored-by: Jannik Stehle <[email protected]>
Based on feedback fom JammingBen
Contributor
Author
|
@JammingBen I took all your feedback into account, please review the current state again. |
JammingBen
approved these changes
Oct 6, 2026
openclouders
pushed a commit
that referenced
this pull request
Oct 6, 2026
fix: prevent app token from being generated more than once
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a user clicks the confirm button when generating a new app token more than once in quick succession, then the app token is generated more than once in the backend, but only one secret might be visible to the user.
There is a similar issue as well when generating invite tokens and this is fixed here as well.
Also, when a the app token generation fails in the backend, then this error would not be shown to the user. It's also fixed here.
It could be possible to generate screenshots for the change, but it's a bit difficult since everything happens rather fast.
Related Issue
None
How Has This Been Tested?
The app token code was tested with this pr being applied to the 8.0.1 version. The error display and the remaining changes were only tested in unit tests.
I would encourage testing this carefully in a review.
Types of changes