thyseus / yii-user-management

a user management module collection for the yii framework
185 stars 122 forks source link

YumProfile timestamp Invalid datetime format #38

Closed Neggia closed 12 years ago

Neggia commented 12 years ago

Hello, with mySql db I got the following error while calling \registration\controllers\YumRegistrationController.php(85): YumUser->register:

CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '1349549588' for column 'timestamp' at row 1. The SQL statement executed was: INSERT INTO tbl_yum_profile (lastname, firstname, show_friends, allow_comments, email, timestamp, user_id) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6)

I changed line 42 in YumProfile.php and it seems ok, from: $this->timestamp = time(); to: $this->timestamp = new CDbExpression('NOW()'); Let me know, sorry if format is wrong, first issue for me, thanks for your extension by the way! Bye

Neggia commented 12 years ago

Another small issue I found: Missing column salt varchar(128) NOT NULL, in fresh_installation.sql

Neggia commented 12 years ago

Another one, seems like function genRandomString was lost in last revision of YumRegistrationForm, here the code I found at http://code.google.com/p/yii-user-management/source/browse/trunk/user/models/YumRegistrationForm.php?r=173 (with some little corrections):

    public static function genRandomString( $length = 10)
    {
$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
$string ='';    
for ($p = 0; $p < $length; $p++)
 {
    $string .= $characters[mt_rand(0, strlen($characters)-1)];
}
return $string;
    }

Need to correct YumUserChangePassword.php, line 44 to: public static function createRandomPassword() { line 59 to: while ($i < $max) { line 81 to: if ($current_lc == $lowercase && $current_uc == $uppercase && $current_dd == $minnumbers && $i < $max) {

Finally, I added this line in YumAuthController->loginByFacebook() before if ($user->save()) { (line 91 for me): $user->status = YumUser::STATUS_ACTIVE;

thyseus commented 12 years ago

i updated the fresh_installation.sql the static has been added. genRandomString has been inserted again. not sure about the timestamp field tough, it should be a integer (unix timestamp)

thanks for reporting to everyone.