From 3e69641ef30759715e6e4f40c5b829b9520dcb13 Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Thu, 14 Jul 2022 18:40:03 -0400 Subject: [PATCH] auth: Use canonical user IDs When adding users to the database, use the canonical user ID from meta.sr.ht. --- auth/middleware.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/auth/middleware.go b/auth/middleware.go index 6a91df21feafb44c23156a9c7691026ccb4930b7..5cce22885fa751e7e2f59c2c5221bffa17de805e 100644 --- a/auth/middleware.go +++ b/auth/middleware.go @@ -337,6 +337,7 @@ func FetchMetaProfile(ctx context.Context, username string, user *AuthContext) e INSERT INTO "user" ( created, updated, + id, username, email, user_type, @@ -348,7 +349,7 @@ func FetchMetaProfile(ctx context.Context, username string, user *AuthContext) e VALUES ( NOW() at time zone 'utc', NOW() at time zone 'utc', - $1, $2, $3, $4, $5, $6, $7 + $1, $2, $3, $4, $5, $6, $7, $8 ) ON CONFLICT DO NOTHING RETURNING @@ -362,8 +363,8 @@ func FetchMetaProfile(ctx context.Context, username string, user *AuthContext) e location, bio, suspension_notice;`, - &profile.Username, &profile.Email, &ut, &profile.URL, - &profile.Location, &profile.Bio, &profile.SuspensionNotice) + profile.ID, profile.Username, profile.Email, ut, profile.URL, + profile.Location, profile.Bio, profile.SuspensionNotice) // TODO: Register webhooks if err := row.Scan(&user.UserID, &user.Created, &user.Updated,