SleepWalker / hoauth

yii-hoauth provides simple integration with social network authorisation lib Hybridauth in Yii.
Other
59 stars 35 forks source link

Logic error in UserOAuth.php #46

Open MihaiMoldovanu opened 10 years ago

MihaiMoldovanu commented 10 years ago

Scenario: Let's say user has 2 gmail accounts aaa@gmail.com and bbb@gmail.com First he logs on the site. It will create the user normally . It logs out and logs back in with the second gmail account . While logged send time on bbb@gmail.com time puts on user email aaa@gmail.com when creating the account.

( i think it can be reproduced by having 2 facebook accounts as well )

It will generate the following error: "Original error message: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-Google' for key 'unic_user_id_name'. The SQL statement executed was: INSERT INTO tbl_user_oauth (provider, profile_cache, identifier, session_data, user_id) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4)"

Error is in UserOAuth.php line 269

    public function bindTo($user_id)
    {
            $this->user_id = $user_id;
            return $this->save();
    }

SleepWalker commented 10 years ago

Yes the problem is, that I have not let two accounts from one provider. I have not thought, that it is necessary. I'll wil fix this soon.

For now you can manually drop unique index for oauth table writting the following sql statement for now:

DROP INDEX `unic_user_id_name` ON `tbl_user_oauth`