Author
|
Message
|
Trevor Clowry
|
Wednesday 23 November 2005 4:59:43 am
Does anyone know a way to change a user's username after it has been created. The username box gets disabled after the user is created. Thanks!
|
Gurudutt Verma
|
Thursday 24 November 2005 1:00:39 am
Hi Trevor Clowry Why you want to change the username ? If it is require to change that better to create new user instead.
|
Trevor Clowry
|
Thursday 24 November 2005 1:44:27 am
Thanks Gurudutt for the reply.
The name of the company that owns the website previously was called RYT, so i had made all the usernames like RYT001, RYT002 etc. However recently they have changed the company name to NAA and was wondering if they could change the usernames to NAA001, NAA002. Since there are over 200 members, I dont want to manually create all the users again.
|
Gurudutt Verma
|
Thursday 24 November 2005 2:59:51 am
Hi Trevor Clowry This is not supported by eZ publish. This is nice requirement, I guess it might be put in suggestion. I haven't tried this, but some kind of script can be created to change that in database, but you have to be very careful and need to take backup of your database first before executing such script. Of cource if you create such script, don't forget to clear all ezsessions before executing this.
|
Łukasz Serwatka
|
Thursday 24 November 2005 3:10:03 am
Changing user names will cause some problems: User passwords are generated by default from username and password. md5( "user\npassword" ); All users logins are in ezuser table. You will have to update user passwords as well if you change logins.
Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog
|
Clemens T
|
Thursday 24 November 2005 3:10:08 am
Ofcourse keep the post of Gurudutt in mind, but here's how I let users edit themselves (even their username):
...
$eztmpuser = eZUser::fetch( $userid );
if(is_object($contentObject) && is_object($eztmpuser)){
$eztmpuser->setAttribute( 'login', $http->postVariable('email') );
$eztmpuser->setAttribute( 'email', $http->postVariable('email') );
$eztmpuser->store();
...
ofCourse you can make a for loop etc.. but you need to know how programming with ezpublish works (the php side of it) to complete this. BACKUP.. before you start :)
|
Clemens T
|
Thursday 24 November 2005 3:12:26 am
Lukasz, this seems untrue, because if I execute the code I just provided, it is still possible to log-in with the old password! (so.. once generated.. the hash still means the same (is my first guess)).
Greets, Clemens
|
Łukasz Serwatka
|
Thursday 24 November 2005 3:17:51 am
Yes, but go to database and change it there, then login in to the system is impossible ;) Of course using script to change logins is good way.
Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog
|
Clemens T
|
Thursday 24 November 2005 3:22:14 am
hahaha, cool comment. Always use the data-access layer when changing data is my philosophy... So, that's why I provided the essence of the login-change-code :).
Greets, Clemens
|
Łukasz Serwatka
|
Thursday 24 November 2005 3:25:43 am
Yeah, I think Trevor will be happy with your code ;)
Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog
|
Trevor Clowry
|
Thursday 24 November 2005 4:19:35 am
Thanks guys for the feedback. Since I know all the old username and password combinations. I have wrote a php script to:
1. Rename all the the logins(in login column of ezuser table) from RYT001 to NAA001 etc
2. Create a new md5 password hash for each user based on the new login and old password.
3. Added the new logins and passwords to the database through the mysql command line.
4. It works! So know i have new logins with the same passwords. Thanks a million Clemens and Lukasz. I really appreciate the feedback.
|
Gurudutt Verma
|
Thursday 24 November 2005 4:56:00 am
Hi Trevor Clowry This was really great discussion and congratulations as you got the solution. btw it is suggested to not use mysql prompt to change stuffs in table use code as suggested by Clemens Timmermans insted that's better and much safe but you got your solution that's great.
|
Clemens T
|
Thursday 24 November 2005 5:19:37 am
Ok, good to hear it has been fixed!
|
Trevor Clowry
|
Thursday 24 November 2005 5:53:43 am
Yep, its working perfectly. Thanks Gurudutt too!
|
Gurudutt Verma
|
Thursday 24 November 2005 6:03:37 am
Hi Trevor Thanks, may be you can share your code here so it could be useful for others :-)
|