eZ Community » Forums » Developer » Changing a user's login
expandshrink

Changing a user's login

Changing a user's login

Monday 17 November 2014 1:37:10 pm - 5 replies

Hello,
I'm trying to change an existing user's login using the eZ Publish 5 public API.
So far, I've tried with the following code:

$userService = $repository->getUserService();
$userUpdateStruct = $repository->newUserUpdateStruct();

$userUpdateStruct->login = ...; // fails !

The code above is not working because the property login does not exist in the structure.
Is there a way to do that using the Public API ?
If not, would it be possible to do that by accessing the storage layer directely ? Maybe by using the classes in the namespace 'eZ\Publish\Core\Persistance' ?

Modified on Monday 17 November 2014 1:40:46 pm by Mickaël Raybaud-Roig

Wednesday 19 November 2014 1:51:54 pm

User objects are kinda complex... If I remember rightly you have to call the contentService/updateStruct to update the data. Could be wrong though, it was a while ago that I tried it.

Monday 24 November 2014 8:11:32 am

Quote from Gareth Arnott :

User objects are kinda complex... If I remember rightly you have to call the contentService/updateStruct to update the data. Could be wrong though, it was a while ago that I tried it.

Yes, I've managed to update some properties of the users with this method, but it looks like updating the login of a user is not possible with the public API suspicious.gif Emoticon
After reflexion, it's something that I can do without though happy.gif Emoticon

Friday 05 December 2014 7:55:17 am

hi,thanks for posting this,i am looking for this

Saturday 06 December 2014 3:10:27 pm

As far as I can tell, it is not possible. In legacy, the login field was greyed out in the admin interface. Based on the UserService implementation, the login clearly ain't meant to be changed.

I'd clearly file this with the "things that come from legacy". I'm not sure it is still required. I guess it would mostly be about how much / if the login was used as a primary key or not.

Monday 08 December 2014 8:12:53 pm

We've written some custom functionality to enable users to change their usernames for some clients on eZ Publish legacy.  With the default password hashing logic at least, your username is used to generate the stored hashed password.  So if you change your username you also have to re-type your password.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from