A more general approach, which also solves the small catch:
The username should always be renamed if it has changed, one exception for this is when the same username exists for another openid-provider. If there is already an user with that username (same provider) then the old_user should be renamed to the name without number (if available) else to the name + first_available_number.
If the same username is kept by another openid-provider, the user should keep its old username (if exists), if a new user is created, it should be username1 (username2 etc which first is available)
A more general approach, which also solves the small catch:
The username should always be renamed if it has changed, one exception for this is when the same username exists for another openid-provider. If there is already an user with that username (same provider) then the old_user should be renamed to the name without number (if available) else to the name + first_available _number.
If the same username is kept by another openid-provider, the user should keep its old username (if exists), if a new user is created, it should be username1 (username2 etc which first is available)
Therefore in the example above: /login. launchpad. net/+id/ AAAA) change name to Ben1 /login. launchpad. net/+id/ ABCD) change name to Ben /login. launchpad. net/+id/ ABCD) logs in => /login. launchpad. net/+id/ AAAA) should be renamed to 'Ben2' /login. launchpad. net/+id/ AAAA) logs in with username 'Ben1' /login. launchpad. net/+id/ ABCD) should be renamed to 'Ben3'
OPENIDPROVIDER
User Ben(https:/
User Cees(https:/
OPENIDCONSUMER
Ben (previous Cees | https:/
user 'Ben1' (https:/
user 'Cees' should be renamed to 'Ben1'
Ben2 (https:/
user 'Ben1' (previous Cees | https:/
user 'Ben2' should be renamed to 'Ben1'
All next logins for Ben3 (Cees/Ben (https:/ /login. launchpad. net/+id/ ABCD)) should check if 'Ben' is available. If not, keep the old username