Password generating

Author Message

Lars Eirik R

Wednesday 16 June 2010 9:51:06 am

Hi.

Is there a utility class i can use in ez API which will allow me to generate passwords once a user registers (it is a custom registration process of mine)

Bertrand Dunogier

Wednesday 16 June 2010 11:38:52 am

Yep, there is. You'll find a few helpful methods in eZUser:

To create a password hash:

eZUser::createHash( $login, $password, eZUser::site(), eZUser::hashType() ) );

Note that the hash type in use should also be stored in the eZUser attribute:

$this->setAttribute( "password_hash", eZUser::createHash( $login, $password, eZUser::site(), eZUser::hashType() ) );
$this->setAttribute( "password_hash_type", eZUser::hashType() );

You can also use the eZUser::validatePassword method in order to make sure the password you'll be using matches the INI settings.

And just in case, there is also an eZUser::createPassword() method if you wanna generate a few.

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.