From 33868a1b612241aae86eeb0594f7de4c63727ee6 Mon Sep 17 00:00:00 2001 From: "tobias.petersen" Date: Mon, 11 Mar 2024 15:02:58 +0100 Subject: [PATCH 1/3] Update API to return 'source_id' for users --- modules/structs/user.go | 2 ++ services/convert/user.go | 1 + 2 files changed, 3 insertions(+) diff --git a/modules/structs/user.go b/modules/structs/user.go index c43558be5d2bf..2383666d7e6f0 100644 --- a/modules/structs/user.go +++ b/modules/structs/user.go @@ -20,6 +20,8 @@ type User struct { // the user's authentication sign-in name. // default: empty LoginName string `json:"login_name"` + // The ID of the user's Authentication Source + SourceID int64 `json:"source_id"` // the user's full name FullName string `json:"full_name"` // swagger:strfmt email diff --git a/services/convert/user.go b/services/convert/user.go index 3521dd2f905c3..1a2733d91e63c 100644 --- a/services/convert/user.go +++ b/services/convert/user.go @@ -75,6 +75,7 @@ func toUser(ctx context.Context, user *user_model.User, signed, authed bool) *ap if authed { result.IsAdmin = user.IsAdmin result.LoginName = user.LoginName + result.SourceID = user.LoginSource result.LastLogin = user.LastLoginUnix.AsTime() result.Language = user.Language result.IsActive = user.IsActive From 1f8d82523d1319fcf74ef7a683af264e1e3af897 Mon Sep 17 00:00:00 2001 From: "tobias.petersen" Date: Tue, 12 Mar 2024 09:40:48 +0100 Subject: [PATCH 2/3] Add field source_id in User object in swagger doc --- templates/swagger/v1_json.tmpl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 221b34b7f8138..1b6c0f8ef740c 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -23475,6 +23475,12 @@ "type": "boolean", "x-go-name": "Restricted" }, + "source_id": { + "description": "The ID of the user's Authentication Source", + "type": "integer", + "format": "int64", + "x-go-name": "SourceID" + }, "starred_repos_count": { "type": "integer", "format": "int64", @@ -24821,4 +24827,4 @@ "TOTPHeader": [] } ] -} +} \ No newline at end of file From bcd61c534143f25c3d25d7330db75c5eaf6b1ecc Mon Sep 17 00:00:00 2001 From: "tobias.petersen" Date: Tue, 12 Mar 2024 09:52:29 +0100 Subject: [PATCH 3/3] Fix: Add new line at end of swagger tamplete --- templates/swagger/v1_json.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 1b6c0f8ef740c..4e581c36846ac 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -24827,4 +24827,4 @@ "TOTPHeader": [] } ] -} \ No newline at end of file +}