jorisdugue/h5p-bundle

string identifier user

Closed this issue · 4 comments

Hello,

I want to use this bundle in an app where users are identified by strings. It doesn't currently work because ContentUserData maps user as an integer. I think it is not a so good choice because H5PInteractionController::getUserId returns a string in some cases.

Anyway i'm aware that changing this would introduce a BC break. So i added a dedicated integer identifier in my User class but i have to override the whole Controller class because this method is private. Turning this method to protected (as suggested in #50) would be a nice solution.

Currently, the H5PInteractionController::getUserId method can be potential to return a string, null, or an integer. This is because I am returning the native result of the Symfony user.

If a user doesn't provide information, the method will return null. However, if the user has a method getId or getUserIdentifier, I will return that, as it is native for each user in Symfony.

I'm not sure it's a good idea to modify this method.

Right no problem in this method.

The problem is that the returned userId is passed to ContentUserData::setUser() and this field is mapped to an integer in the database so a string value cannot work here.

Right, your suggestion makes sense. It might be a good idea to substitute the string value with a default number, such as 0. This action would effectively exchange the character string "anon." (which corresponds to the tokenStorage of our user) with a fictional identifier. This approach aims to maintain the integrity of the model's relationships without causing any disruptions.

Just handling "anon." user is not suitable for my use case. In my app, User::id is a string. User::getId and User::getUserIdentifier always return a string so i really need a way to override H5PInteractionController::getUserId. Making it protected would do the job.