From 649042f925f7c24db74f02d669a0785db75ea9fe Mon Sep 17 00:00:00 2001 From: Baekjun Kim <36013575+kimbj95@users.noreply.github.com> Date: Fri, 15 Jul 2022 01:52:11 -0700 Subject: [PATCH] Include login_name in adminCreateUser response (#20283) `login_name` (Authentication Sign-in Name) is not included in the response of `adminUserCreate` API. This PR is to return user-specified `login_name` if there is one. --- modules/convert/user.go | 1 + modules/structs/user.go | 3 +++ templates/swagger/v1_json.tmpl | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/modules/convert/user.go b/modules/convert/user.go index 2b07d21838d71..093994856cae7 100644 --- a/modules/convert/user.go +++ b/modules/convert/user.go @@ -73,6 +73,7 @@ func toUser(user *user_model.User, signed, authed bool) *api.User { // only site admin will get these information and possibly user himself if authed { result.IsAdmin = user.IsAdmin + result.LoginName = user.LoginName result.LastLogin = user.LastLoginUnix.AsTime() result.Language = user.Language result.IsActive = user.IsActive diff --git a/modules/structs/user.go b/modules/structs/user.go index 431e230fac038..81516894a58f9 100644 --- a/modules/structs/user.go +++ b/modules/structs/user.go @@ -17,6 +17,9 @@ type User struct { ID int64 `json:"id"` // the user's username UserName string `json:"login"` + // the user's authentication sign-in name. + // default: empty + LoginName string `json:"login_name"` // the user's full name FullName string `json:"full_name"` // swagger:strfmt email diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 71a43012e929d..a19738b2a0501 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -18963,6 +18963,12 @@ "type": "string", "x-go-name": "UserName" }, + "login_name": { + "description": "the user's authentication sign-in name.", + "type": "string", + "default": "empty", + "x-go-name": "LoginName" + }, "prohibit_login": { "description": "Is user login prohibited", "type": "boolean",