Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent accidental update of user types when referencing current user #28

Merged
merged 2 commits into from
Dec 6, 2023

Conversation

ledsoft
Copy link

@ledsoft ledsoft commented Dec 5, 2023

Should prevent kbss-cvut/record-manager-ui#23, which was likely caused by using the currently logged in user (which is retrieved from the repository) in a transaction. If the current user was impersonated, a special type is added to it, and if this happens in a transaction, this update is written to the repository.

The fix lies in using a copy of the retrieved user instance that is detached from the persistence context.

@ledsoft ledsoft requested a review from blcham December 5, 2023 09:24
Copy link

@blcham blcham left a comment

Choose a reason for hiding this comment

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

I am not sure about one line, otherwise LGTM

src/main/java/cz/cvut/kbss/study/model/User.java Outdated Show resolved Hide resolved
Co-authored-by: Miroslav Blaško <blcham@gmail.com>
@blcham blcham merged commit bff6079 into kbss-cvut:main Dec 6, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants