Merge pull request #39 from butonic/use-ocs-bool

Mimic oc10 user enabled as string in provisioning api
This commit is contained in:
Jörn Friedrich Dreyer
2020-08-26 17:31:01 +02:00
committed by GitHub
3 changed files with 23 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
Bugfix: Mimic oc10 user enabled as string in provisioning api
The oc10 user provisioning API uses a string for the boolean `enabled` flag. 😭
https://github.com/owncloud/ocis-ocs/pull/39

View File

@@ -8,7 +8,7 @@ type Users struct {
// User holds the payload for a GetUser response
type User struct {
// TODO needs better naming, clarify if we need a userid, a username or both
Enabled bool `json:"enabled" xml:"enabled"`
Enabled string `json:"enabled" xml:"enabled"`
UserID string `json:"id" xml:"id"`
Username string `json:"username" xml:"username"`
DisplayName string `json:"displayname" xml:"displayname"`

View File

@@ -56,6 +56,13 @@ func (o Ocs) GetUser(w http.ResponseWriter, r *http.Request) {
}
o.logger.Debug().Interface("account", account).Msg("got user")
// mimic the oc10 bool as string for the user enabled property
var enabled string
if account.AccountEnabled {
enabled = "true"
} else {
enabled = "false"
}
render.Render(w, r, response.DataRender(&data.User{
UserID: account.Id, // TODO userid vs username! implications for clients if we return the userid here? -> implement graph ASAP?
Username: account.PreferredName,
@@ -63,8 +70,8 @@ func (o Ocs) GetUser(w http.ResponseWriter, r *http.Request) {
Email: account.Mail,
UIDNumber: account.UidNumber,
GIDNumber: account.GidNumber,
Enabled: account.AccountEnabled,
// FIXME only return quota for users/{userid} endpoint (not /user)
Enabled: enabled,
// FIXME onlyfor users/{userid} endpoint (not /user)
// TODO query storage registry for free space? of home storage, maybe...
Quota: &data.Quota{
Free: 2840756224000,
@@ -160,6 +167,13 @@ func (o Ocs) AddUser(w http.ResponseWriter, r *http.Request) {
}
o.logger.Debug().Interface("account", account).Msg("added user")
// mimic the oc10 bool as string for the user enabled property
var enabled string
if account.AccountEnabled {
enabled = "true"
} else {
enabled = "false"
}
render.Render(w, r, response.DataRender(&data.User{
UserID: account.Id,
Username: account.PreferredName,
@@ -167,7 +181,7 @@ func (o Ocs) AddUser(w http.ResponseWriter, r *http.Request) {
Email: account.Mail,
UIDNumber: account.UidNumber,
GIDNumber: account.UidNumber,
Enabled: account.AccountEnabled,
Enabled: enabled,
}))
}