User Details Update

Hi

I’m pretty new to this framework (just been a couple days). I am trying to create a user login and management for my website. Ofcourse it would require a view to update the user details later, and the admin should have rights to edit details of all users. I have all the users (including admins) in a Users Table.

The problem is that the view display all the fields in the Table including the password field. Now if the Admin wants to change the email ID of a user A, the view is displaying the password too from the database (which, as far as i know is a hashed or MD5 of the actual password). I could comment it out so the password isn’t displayed.

But the real problem is that when the Admin updates the details using the view, the hashed value of the password is again getting hashed, which literally changes the password to something else.

I have tried searching the forums for a solution, but I’m not sure what exact things I’ll need to avoid this. Pleas help.

I’m sorry if this has already been answered.

Hi and welcome,

please use the search - this is (or at least was) a very frequently asked question:

http://www.yiiframew…rch/?q=password

EDIT:

After reading your post completely, i see you already tried searching. Ok, there are a lot of results - so here you go:

http://www.yiiframework.com/forum/index.php?/topic/6451-rehash-password-only-when-changed/page__view__findpost__p__33180

Depending on what you need there are different solutions…

If you need just a form for changing the user details… you can just remove the password input field from the view…

If you need a form to update the user details that will update the details only when the users enters his current password… you can save the current md5 hash and unset the password attribute before rendering the view…




$this->usermd5=$model->password;

$model->password='';



and then before saving you check that the md5 of the entered password is the same as the remembered one… and save the data only if they are the same…

If you need a form so that the user/admin can change the password… check the posts on the forum like Mike suggested… .there are few examples…

And welcome to the Yii forum :D