Skip to content

Conversation

@InJoDave
Copy link
Contributor

Replaced userid with username as column value to be displayed in User Events tab

Fixes : #39357

Signed-off-by: Indu John [email protected]

@InJoDave
Copy link
Contributor Author

@edewit new PR raised for your review. Username will be displayed instead of user id as a link. On clicking the link the details will be shown as was previously with user id

image

@InJoDave
Copy link
Contributor Author

@mpawlus for your review, requested changes done in this PR

@InJoDave InJoDave force-pushed the add-username-to-events-updated branch from 6922203 to 77da542 Compare May 12, 2025 13:01
@mpawlus
Copy link

mpawlus commented May 12, 2025

@InJoDave When looking at the failing builds, it seems like there is an issue with the migration:
image

Maybe there should be a check in the changeSet to only add column if it does not exist (see https://stackoverflow.com/a/59373495)?
EDIT: I found out this approach has already been used in other changelogs:

@edewit Do you have an idea why this could be happening?

@InJoDave
Copy link
Contributor Author

@mpawlus let me try this approach and push the changes.

@InJoDave InJoDave force-pushed the add-username-to-events-updated branch from 811026c to 0cbf0d1 Compare May 13, 2025 06:23
@InJoDave
Copy link
Contributor Author

@mpawlus the migration checks are now ok, the ones now failing seems to be for the test cases...will try my best to solve them as well.

@InJoDave
Copy link
Contributor Author

@mpawlus Could you please check the changes now? There are some failing for which I need some help

InJoDave added 2 commits May 19, 2025 13:16
…s as before and propagate its value automatically in EventBuilder same like userid

Signed-off-by: Indu John <[email protected]>
…s as before and propagate its value automatically in EventBuilder same like userid

Signed-off-by: Indu John <[email protected]>
@mpawlus
Copy link

mpawlus commented May 19, 2025

@InJoDave Would you be able to fix the failing UI test? I believe it's caused by the changes in js/apps/admin-ui/src/events/UserEvents.tsx, so the test needs to be updated now.

@ahus1 ahus1 dismissed their stale review May 19, 2025 20:58

obsolete

@ahus1
Copy link
Contributor

ahus1 commented May 19, 2025

@InJoDave - unfortunately I will not have the time to review this PR in the next two weeks. I will come back to it later. I dismissed my previous comment as the changes have been addressed to unblock this in case someone else wants to review it.

@InJoDave
Copy link
Contributor Author

@InJoDave Would you be able to fix the failing UI test? I believe it's caused by the changes in js/apps/admin-ui/src/events/UserEvents.tsx, so the test needs to be updated now.

Sure will work on it

@mpawlus
Copy link

mpawlus commented May 21, 2025

@InJoDave I think I might have a fix for one of the issues, but I can't push anymore, I keep getting 403 response - can you please double-check if I am still a contributor?

@ahus1 ahus1 self-assigned this May 21, 2025
@InJoDave
Copy link
Contributor Author

InJoDave commented May 25, 2025

@InJoDave I think I might have a fix for one of the issues, but I can't push anymore, I keep getting 403 response - can you please double-check if I am still a contributor?

I have added you @mpawlus as well as @ahus1 as contributor. You can merge the test changes @mpawlus. Sorry for late reply and thank you for the same.

@mpawlus mpawlus force-pushed the add-username-to-events-updated branch from 655ecba to b9de961 Compare May 26, 2025 09:51
@InJoDave
Copy link
Contributor Author

InJoDave commented Jun 3, 2025

@mpawlus / @ahus1 is this still needing some change?

@mpawlus
Copy link

mpawlus commented Jun 4, 2025

@mpawlus / @ahus1 is this still needing some change?

@InJoDave I think we're now waiting for @ahus1 to review it, which should also trigger the workflows.

@mpawlus mpawlus force-pushed the add-username-to-events-updated branch from 28051fd to 68a352a Compare June 10, 2025 12:33
@mabartos
Copy link
Contributor

@mpawlus Could you please resolve these conflicts?

@mpawlus mpawlus force-pushed the add-username-to-events-updated branch from 46a5366 to 555aa5a Compare June 12, 2025 12:03
@mpawlus
Copy link

mpawlus commented Jun 12, 2025

@mpawlus Could you please resolve these conflicts?

@mabartos Done.

@mpawlus
Copy link

mpawlus commented Jun 23, 2025

@mabartos @ahus1 @edewit Can you please review?

@mpawlus
Copy link

mpawlus commented Jul 30, 2025

@mabartos @ahus1 @edewit Can you please review?

Bump

Copy link
Contributor

@ahus1 ahus1 left a comment

Choose a reason for hiding this comment

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

Thank you for the changes, and sorry for the wait.

I had a look and when I scrolled to the end of the PR, I saw that several test cases are changed as now a different username is recorded.

IMHO this would be a breaking change to those who are parsing the events, and that want to see how a user logged in: either with a username, or an email address, etc.

See below for one example where adding the username can be safely removed, and another example where to keep the username.

As a test, all changes to the test cases that relate to a change in the username should then be reverted as well.

}

event.user(userSession.getUser())
.detail(Details.USERNAME, username)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an example where the username should be stored as entered by the user, as we don't want to change the logic of existing events. It might sometimes be important to know what the user actually entered in the form.

So this line and similar ones should be restored.

eventBuilder.event(EventType.DELETE_ACCOUNT)
.client(keycloakContext.getClient())
.user(user)
.detail(Details.USERNAME, user.getUsername())
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing this line is fine, as here the username is picked from the user, identical to what we do when constructing the event when passing in the user.

)}
{!event.userId && t("noUserDetails")}
</>
return userId && userName ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

This change now requires both userId and userName to be set. But there are a lot of old events in the database that have a userId, but no username. And those are connected to a user. Those should be displayed with the userID and should link to the user (as before).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Username missing in the logout event

6 participants