From 077ff9a879890d6490fe1625b8b7491d7269eb73 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Thu, 11 Apr 2024 00:50:56 +0200 Subject: [PATCH] Add canChangePassword to group status. --- group/group.go | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/group/group.go b/group/group.go index 63e488b..e92a990 100644 --- a/group/group.go +++ b/group/group.go @@ -855,11 +855,11 @@ type Configuration struct { modTime time.Time `json:"-"` fileSize int64 `json:"-"` - PublicServer bool `json:"publicServer"` - CanonicalHost string `json:"canonicalHost"` - ProxyURL string `json:"proxyURL"` - WritableGroups bool `json:"writableGroups"` - Users map[string]UserDescription + PublicServer bool `json:"publicServer"` + CanonicalHost string `json:"canonicalHost"` + ProxyURL string `json:"proxyURL"` + WritableGroups bool `json:"writableGroups"` + Users map[string]UserDescription // obsolete fields Admin []ClientPattern `json:"admin"` @@ -1031,16 +1031,17 @@ func (g *Group) GetPermission(creds ClientCredentials) (string, []string, error) } type Status struct { - Name string `json:"name"` - Redirect string `json:"redirect,omitempty"` - Location string `json:"location,omitempty"` - Endpoint string `json:"endpoint,omitempty"` - DisplayName string `json:"displayName,omitempty"` - Description string `json:"description,omitempty"` - AuthServer string `json:"authServer,omitempty"` - AuthPortal string `json:"authPortal,omitempty"` - Locked bool `json:"locked,omitempty"` - ClientCount *int `json:"clientCount,omitempty"` + Name string `json:"name"` + Redirect string `json:"redirect,omitempty"` + Location string `json:"location,omitempty"` + Endpoint string `json:"endpoint,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + AuthServer string `json:"authServer,omitempty"` + AuthPortal string `json:"authPortal,omitempty"` + Locked bool `json:"locked,omitempty"` + ClientCount *int `json:"clientCount,omitempty"` + CanChangePassword bool `json:"canChangePassword,omitempty"` } // Status returns a group's status. @@ -1097,6 +1098,12 @@ func (g *Group) Status(authentified bool, base *url.URL) Status { d.Locked = locked d.ClientCount = &count } + if authentified { + conf, err := GetConfiguration() + if err == nil { + d.CanChangePassword = conf.WritableGroups + } + } return d }