hoauth icon indicating copy to clipboard operation
hoauth copied to clipboard

Logic error in UserOAuth.php

Open MihaiMoldovanu opened this issue 11 years ago • 1 comments

Scenario: Let's say user has 2 gmail accounts [email protected] and [email protected] 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 [email protected] time puts on user email [email protected] 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();
    }

MihaiMoldovanu avatar Jun 03 '14 22:06 MihaiMoldovanu

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`

SleepWalker avatar Jun 22 '14 10:06 SleepWalker