Page MenuHomePhabricator

Quarry should update username when a user is renamed
Closed, ResolvedPublic

Description

The first time I logged in to Quarry was before my global account was renamed.

Now, if I go to
http://quarry.wmflabs.org/
and click in the login button, it shows

Hi He7d3r,

SQL Quarry would like to have basic
access on your behalf on
meta.wikimedia.org.

(which uses my current username).
However, after I click in the button to allow the login, it shows my old username in the top right corner, with a link using the old username:
http://quarry.wmflabs.org/Helder.wiki
The correct link
http://quarry.wmflabs.org/He7d3r
returns "502 Bad Gateway"

How can I force it to use the new username?

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:57 AM
bzimport added a project: Quarry.
bzimport set Reference to bz71064.
bzimport added a subscriber: Unknown Object (MLST).
He7d3r set Security to None.

Hmm, good question. I'm not particularly sure how to do this...

I don't know if it is related but, I have a similar problem with the Wikidata Game, which also uses OAuth:
https://bitbucket.org/magnusmanske/wikidata-game/issue/153/stats-are-lost-after-a-global-account

It's probably a similar issue - we just cache the name OAuth gives us in the db and do not change it every login. We perhaps should...

It's probably a similar issue - we just cache the name OAuth gives us in the db and do not change it every login. We perhaps should...

@yuvipanda: So I thought about doing that. I spent a while setting stuff up in beta, filing bugs for the various issues I encountered along the way, etc., and then I wrote a quick patch. But just before I went to test the patch, I realised this might happen:

  • A and B exist as users in Quarry.
  • A renames to C
  • B renames to A
  • B logs into Quarry (C, previously known as A, doesn't)
  • ... now we have two As? The username field is supposed to be unique according to tables.sql.

@Legoktm: That's a possible situation, right? Or do we disallow renaming to usernames that were taken in the past?

  • ... now we have two As? The username field is supposed to be unique according to tables.sql.

This may also happen even if you do not implement user renames in Quarry. Consider the following situation:

  • A and B both have SUL accounts. A has a Quarry account, but B has no Quarry account.
  • A renames to C. C (previously A) remains Quarry user A because Quarry doesn't rename users.
  • B renames to A.
  • A (previously B) logs in to Quarry for the first time. Since A (previously B) hasn't logged in before, Quarry creates an account for A (previously B) under his current user name, A.

Now there are two "User:A" on Quarry.

I do not know hot it is build so do not know if that might occur (well hopefully it is based on IDs and not on usernames behind the scenes so it might not), but I hope that those renames if you made them will not just create a second account for new username of a user and thus leave the first one orphaned. As it would be unfortunate to stack orphaned accounts.

He7d3r renamed this task from Quarry shows old username after user was renamed to Quarry should update username when a user is renamed.Dec 17 2017, 12:44 PM

Change 398711 had a related patch set uploaded (by Zhuyifei1999; owner: Zhuyifei1999):
[analytics/quarry/web@master] Update username in database when a renamed user logins.

https://gerrit.wikimedia.org/r/398711

Change 398711 merged by jenkins-bot:
[analytics/quarry/web@master] Update username in database when a renamed user logins

https://gerrit.wikimedia.org/r/398711

Framawiki assigned this task to zhuyifei1999.
Framawiki added a subscriber: Framawiki.

Tested after the merge of the above patch by

  1. Creating a test account on WM and log in into quarry
  2. Rename this account
  3. Confirming that, still logged in into quarry, the old username is still shown in the top right corner of the site
  4. By disconnect and log in again, new user is shown
  5. The new userpage is correctly rendered, but the old says "User not found".

It's not ideal, but it seems enough to me to close this task.

If you couldn't connect because of a renaming, you should be able to do so now.

Mentioned in SAL (#wikimedia-cloud) [2018-09-17T17:40:59Z] <framawiki> deployed e8e6e02 to quarry-web-01 T73064