Skip to content

use zauth id's so usernames can be updated (and use zpi for profile images!)#220

Merged
hanneskt merged 14 commits intomasterfrom
zpi_images
Jan 30, 2026
Merged

use zauth id's so usernames can be updated (and use zpi for profile images!)#220
hanneskt merged 14 commits intomasterfrom
zpi_images

Conversation

@hanneskt
Copy link
Copy Markdown
Member

@hanneskt hanneskt commented Dec 15, 2025

closes #216

this is the first step in using zauth id's for syncing transactions as well

@hanneskt hanneskt requested a review from TomNaessens December 15, 2025 22:27
@hanneskt hanneskt changed the title use zauth id's so usernames can be updates (and use zpi for profile images!) use zauth id's so usernames can be updated (and use zpi for profile images!) Dec 15, 2025
Comment thread app/models/user.rb Outdated
Comment thread app/models/user.rb Outdated
Comment thread app/models/user.rb Outdated
Comment thread app/models/user.rb Outdated
end

# overwrite name (for if name changed)
db_user.name = auth.uid
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative here would be to just take some downtime and do a migration where we prepare a mapping of usernames to ZAuth id's, and fill them in the database. That way, the whole table will be filled, we can make the zauth_id a non-nullable column, and there's no need for changes like these in code.

@@ -0,0 +1,5 @@
class AddZauthIdToUsers < ActiveRecord::Migration[6.1]
def change
add_column :users, :zauth_id, :integer
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're finding by zauth_id, having an index here would be nice. Together with https://github.com/ZeusWPI/Tap/pull/220/changes#r2622094045, we could even make this non nullable after doing the migration.

Comment thread app/models/user.rb Outdated
@@ -0,0 +1,5 @@
class AddZauthIdToUsers < ActiveRecord::Migration[6.1]
def change
add_column :users, :zauth_id, :integer
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this get a unique constraint? Having two users with the same id would be strange and should throw some error.

@jnms-me
Copy link
Copy Markdown
Contributor

jnms-me commented Dec 23, 2025

↑ Rebased on master, re-creating the migrations.

@hanneskt
Copy link
Copy Markdown
Member Author

we will deploy this now, fill the column with the zauthids and then make the not null in a future PR

@hanneskt hanneskt merged commit fbe2b54 into master Jan 30, 2026
5 checks passed
@hanneskt hanneskt deleted the zpi_images branch January 30, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZPI integration

4 participants