PSA with Django, works as expected except for an apparent, and worrisome change of users:
During Twitter OAuth pipeline processing, our system at first reports the expected Twitter username
/uid
(matching "id" and "screen_name", cf. 38200000 below). But then at some stage (social.pipeline.user.get_username
?) a pipeline function reports a user that seems rather surprising, a user object that does not seem to represent the Twitter user, but a Google user. (See (2, "person.1")
in table "auth_user" below).
Is it correct to assume that the User object that is made during OAuth request processing is not produced directly form the "social_auth_usersocialauth" backed model class, but eventually from the "auth_user" backed one (via foreign key)? How are the tables related when users are created? Searching the bowels of PSA, I found this
return cls.objects.select_related('user').get(provider=provider,
uid=uid)
in social.apps.django_app.default.models.UserSocialAuth
. Consistent with the tables listed below, I'm guessing that this could mean: "social_auth_usersocialauth"."user_id"
being a
non-unique foreign key, PSA finds (2, "person.1") in "auth_user"
below. Therefore, we get a user object for provider Google, not Twitter.
sqlite> SELECT id, user_id, provider, uid FROM social_auth_usersocialauth
;
1|2|google-oauth2|email.1@googlemail.com
2|3|google-oauth2|fst.lst@gmail.com
3|2|twitter|382000000
sqlite> SELECT id, username, email FROM auth_user
;
1|foo-bar|technique@somewhere.de
2|person.1|email.1@googlemail.com
3|fst.lst|fst.lst@gmail.com
Note that 2
occurs twice in the user_id
column of the first table.
If the relation (OAuth User):(Django user) is not 1:1 by default, is there a way we can make it 1:1? Or have our tables become corrupted or some such? (PSA 0.2.12)