Dumb Newbie Need Password Hashing Help

I’m trying to develop a simple set of screens for an admin to use to maintain users.

I’ve put in srbac.

I’ve got a user table with user id, user name, password and salt fields.

I’ve put in the public functions validatePassword($password), hashPassword($password,$salt), & generateSalt()

I know I need to generateSalt, then hash the user entered password before I save it.

Where should I do this? In beforeSave? Should I put beforeSave in the model or the controller? What does the code look like? Is there any place where I can see a functional snippet of this code? Am I missing something simple (as usual)?


Take a look at the Yii blog tutorial - http://www.yiiframework.com/doc/blog/start.overview

Yii blog tutorial, authenticating user - http://www.yiiframework.com/doc/blog/prototype.auth

Thanks so much for the reply, but I saw that, and working from that is what caused my trouble.

From that link: "Note that this blog system does not provide the user management feature. As a result, a user cannot change his account or create a new one through the Web interface. The user management feature may be considered as a future enhancement to the blog application."

The blog tutorial leaves making a user management module up to the programmer and that is the part I cannot figure out.

Yes you should use YourModel::beforeSave().

Some threads with code example: #1, #2, #3