• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed user_id key Within xf_user_external_auth

digitalpoint

Well-known member
#1
Is it intended that the table has two different unique indexes?

provider + provider_key definitely should be unique, but with user_id being a unique primary key, it means we can never have more than one external auth service per user because XenForo_Model_UserExternal->updateExternalAuthAssociation() does "ON DUPLICATE KEY UPDATE" if the user_id isn't unique even if the provider is different.
 

Mike

XenForo developer
Staff member
#2
That table's weird. I think the primary key should be (user_id, provider). I don't even know if it needs a unique key on (provider, provider_key).
 

Deebs

Well-known member
#4
Mike,

Can you confirm that the PKEY should be (user_id, provider). I am wanting to link multiple external authentication methods to user accounts and want to be sure I am aligned with your schema.
 

Morgan

Active member
#7
Here is a simple SQL statement to fix this issue (until it is released formally by XenForo):
Code:
ALTER TABLE xf_user_external_auth DROP PRIMARY KEY, ADD PRIMARY KEY (user_id, provider);
Tested that this allowed multiple external identity providers for a single user and does exactly what is described in this thread.