diff options
author | Tobias Balle-Petersen <tobiasbp@gmail.com> | 2024-04-16 08:08:48 +0200 |
---|---|---|
committer | Gergely Nagy <forgejo@gergo.csillger.hu> | 2024-04-21 12:04:18 +0200 |
commit | 23f032eaa5cea8a71d5336c32cb2b6848dac284a (patch) | |
tree | e66d9bdd881c5edff706697edc745d6974306c4f | |
parent | Fix empty field `login_name` in API response JSON when creating user (#30511) (diff) | |
download | forgejo-23f032eaa5cea8a71d5336c32cb2b6848dac284a.tar.xz forgejo-23f032eaa5cea8a71d5336c32cb2b6848dac284a.zip |
Update API to return 'source_id' for users (#29718)
Using the API, a user's _source_id_ can be set in the _CreateUserOption_
model, but the field is not returned in the _User_ model.
This PR updates the _User_ model to include the field _source_id_ (The
ID of the Authentication Source).
(cherry picked from commit 58b204b813cd3a97db904d889d552e64a7e398ff)
-rw-r--r-- | modules/structs/user.go | 2 | ||||
-rw-r--r-- | services/convert/user.go | 1 | ||||
-rw-r--r-- | templates/swagger/v1_json.tmpl | 6 |
3 files changed, 9 insertions, 0 deletions
diff --git a/modules/structs/user.go b/modules/structs/user.go index 82b565e5e7..ad529c966e 100644 --- a/modules/structs/user.go +++ b/modules/structs/user.go @@ -19,6 +19,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 98db53705b..789bc51097 100644 --- a/services/convert/user.go +++ b/services/convert/user.go @@ -76,6 +76,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 diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index cc4e50e60d..c68a90a4c5 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -24672,6 +24672,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", |