From f8335444de91796f8a90bb108f53bf432012366d Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Tue, 11 May 2021 02:22:29 +0200 Subject: [PATCH] Add Active and ProhibitLogin to API (#15689) * Added active and prohibit_login. * Do not omit fields for normal users. --- modules/convert/user.go | 2 ++ modules/structs/user.go | 4 ++++ templates/swagger/v1_json.tmpl | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/modules/convert/user.go b/modules/convert/user.go index 364914f2ad02..088ede5add50 100644 --- a/modules/convert/user.go +++ b/modules/convert/user.go @@ -58,6 +58,8 @@ func toUser(user *models.User, signed, authed bool) *api.User { result.IsAdmin = user.IsAdmin result.LastLogin = user.LastLoginUnix.AsTime() result.Language = user.Language + result.IsActive = user.IsActive + result.ProhibitLogin = user.ProhibitLogin } return result } diff --git a/modules/structs/user.go b/modules/structs/user.go index b5d5b9298ef0..2dbc5305382a 100644 --- a/modules/structs/user.go +++ b/modules/structs/user.go @@ -33,6 +33,10 @@ type User struct { Created time.Time `json:"created,omitempty"` // Is user restricted Restricted bool `json:"restricted"` + // Is user active + IsActive bool `json:"active"` + // Is user login prohibited + ProhibitLogin bool `json:"prohibit_login"` // the user's location Location string `json:"location"` // the user's website diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 8255ed6e6ea4..e3ac4a4c8a68 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -16250,6 +16250,11 @@ "description": "User represents a user", "type": "object", "properties": { + "active": { + "description": "Is user active", + "type": "boolean", + "x-go-name": "IsActive" + }, "avatar_url": { "description": "URL to the user's avatar", "type": "string", @@ -16306,6 +16311,11 @@ "type": "string", "x-go-name": "UserName" }, + "prohibit_login": { + "description": "Is user login prohibited", + "type": "boolean", + "x-go-name": "ProhibitLogin" + }, "restricted": { "description": "Is user restricted", "type": "boolean",