From 97e948b39543e3010bd445dc75ba77d02232015d Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sat, 1 May 2021 08:46:36 +0000 Subject: [PATCH 1/2] Added active and prohibit_login. --- 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 f3a33aee411d1..00ca34e4a5aa2 100644 --- a/modules/convert/user.go +++ b/modules/convert/user.go @@ -55,6 +55,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 9e021e40fe880..60dc5491300a7 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,omitempty"` + // Is user login prohibited + ProhibitLogin *bool `json:"prohibit_login,omitempty"` } // MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 5aeed4a30f493..c3fea6feff2d2 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -16246,6 +16246,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", @@ -16292,6 +16297,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", From c9db85e93a8aec14875722d541d74bc82293e653 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Fri, 7 May 2021 07:14:00 +0200 Subject: [PATCH 2/2] Do not omit fields for normal users. --- modules/convert/user.go | 4 ++-- modules/structs/user.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/convert/user.go b/modules/convert/user.go index 8e0172011cc18..088ede5add507 100644 --- a/modules/convert/user.go +++ b/modules/convert/user.go @@ -58,8 +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 + result.IsActive = user.IsActive + result.ProhibitLogin = user.ProhibitLogin } return result } diff --git a/modules/structs/user.go b/modules/structs/user.go index 37aee5417ac00..2dbc5305382ab 100644 --- a/modules/structs/user.go +++ b/modules/structs/user.go @@ -34,9 +34,9 @@ type User struct { // Is user restricted Restricted bool `json:"restricted"` // Is user active - IsActive *bool `json:"active,omitempty"` + IsActive bool `json:"active"` // Is user login prohibited - ProhibitLogin *bool `json:"prohibit_login,omitempty"` + ProhibitLogin bool `json:"prohibit_login"` // the user's location Location string `json:"location"` // the user's website