From e35a39e81d9ef548b17612b6441951eb08b4345e 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 2b07d21838..093994856c 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 431e230fac..81516894a5 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 4b24cb729d..a3bb904845 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -18487,6 +18487,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",