fix(license): ensure IP address is included in anonymous user payload#163
Open
amadulhaxxani wants to merge 2 commits into
Open
fix(license): ensure IP address is included in anonymous user payload#163amadulhaxxani wants to merge 2 commits into
amadulhaxxani wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes anonymous CLARIN license acceptance by ensuring the POST payload to the CLARIN user metadata manage endpoint always includes an IP metadata entry, even when no extra fields are required and userMetadata$ was never initialized for anonymous users.
Changes:
- Initialize
userMetadata$to an emptyPaginatedListwhen missing (or when itspageis missing) before filtering/pushing the IP entry. - Add unit tests covering anonymous-user acceptance when
userMetadata$isnulland when it contains an empty page array.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/app/bitstream-page/clarin-license-agreement-page/clarin-license-agreement-page.component.ts | Initializes userMetadata$ to guarantee an array exists for adding the IP metadata before sending the POST request. |
| src/app/bitstream-page/clarin-license-agreement-page/clarin-license-agreement-page.component.spec.ts | Adds tests asserting the request payload contains the IP metadata for anonymous users in the two affected initialization states. |
d87e662 to
0e911f3
Compare
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.
Problem description
When an anonymous user accepts a CLARIN license that does not require any additional user fields, the POST request to
/core/clarinusermetadata/manageis sent with an empty body.This happens because
userMetadata$is never initialised for anonymous users – theloadUserRegistrationAndUserMetadata()method is only called for authenticated users. As a result, the IP address is missing from the payload and the backend rejects the request.Analysis
The
accept()method expectsuserMetadata$.value.pageto be an array before it pushes the IP metadata. For anonymous users who do not interact with any form fields, this array remainsundefined.The fix initialises an empty page array using
buildPaginatedListbefore the IP filtering logic, ensuring the IP metadata is always included.Unit tests were added to cover the two affected cases:
userMetadata$isnull, anduserMetadata$has an emptypagearray.Copilot review