so the question may seem very unclear and I'm sorry but I will explain better here. I am currently working on a feature where you can ban users from an app. In the database, each user has an unique userId
and I was thinking on banning based on that.
To ban a user from a room, I thought about adding an entry to a new table called bannedUser
, which has 3 columns: id
(randomly generated, primary key), roomId
and userId
(both foreign keys). Now each user has an username, which I display in a list of participants to the room. To do that, I have a method that gets all users in a room and returns a List<User>
, which I then map to a List<String>
with only the usernames. This means that I lose the userId
. Now if I want to ban a user, I have to provide the userId
and since usernames are not unique, I cannot search for it using just the username.
Therefore, I'm asking for help. I don't know exactly how I should do this. Let's say a moderator clicks a ban user button. This gets all users in the room and creates a pop-up with all usernames. Where and how should I store the userId
s for each username without revealing them to the moderator?