Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
Add UidNumber and GidNumber when creating new user
Browse files Browse the repository at this point in the history
  • Loading branch information
dpakach committed Aug 10, 2020
1 parent 43514cd commit def5934
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/service/v0/data/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type User struct {
DisplayName string `json:"displayname" xml:"displayname"`
Email string `json:"email" xml:"email"`
Quota *Quota `json:"quota" xml:"quota"`
UIDNumber int64 `json:"uidNumber" xml:"uidNumber"`
GIDNumber int64 `json:"gidNumber" xml:"gidNumber"`
}

// Quota holds quota information
Expand Down
20 changes: 20 additions & 0 deletions pkg/service/v0/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"fmt"
"net/http"
"strconv"
"strings"

"github.com/cs3org/reva/pkg/user"
Expand Down Expand Up @@ -60,6 +61,8 @@ func (o Ocs) GetUser(w http.ResponseWriter, r *http.Request) {
Username: account.PreferredName,
DisplayName: account.DisplayName,
Email: account.Mail,
UIDNumber: account.UidNumber,
GIDNumber: account.GidNumber,
Enabled: account.AccountEnabled,
// FIXME only return quota for users/{userid} endpoint (not /user)
// TODO query storage registry for free space? of home storage, maybe...
Expand All @@ -81,6 +84,21 @@ func (o Ocs) AddUser(w http.ResponseWriter, r *http.Request) {
username := r.PostFormValue("username")
displayname := r.PostFormValue("displayname")
email := r.PostFormValue("email")
uid := r.PostFormValue("uidNumber")
gid := r.PostFormValue("gidNumber")

uidNumber, err := strconv.ParseInt(uid, 10, 64)
if err != nil {
render.Render(w, r, response.ErrRender(data.MetaBadRequest.StatusCode, "Cannot use the uidNumber provided"))
o.logger.Error().Err(err).Str("userid", userid).Msg("Cannot use the uidNumber provided")
return
}
gidNumber, err := strconv.ParseInt(gid, 10, 64)
if err != nil {
render.Render(w, r, response.ErrRender(data.MetaBadRequest.StatusCode, "Cannot use the gidNumber provided"))
o.logger.Error().Err(err).Str("userid", userid).Msg("Cannot use the gidNumber provided")
return
}

// fallbacks
/* TODO decide if we want to make these fallbacks. Keep in mind:
Expand All @@ -99,6 +117,8 @@ func (o Ocs) AddUser(w http.ResponseWriter, r *http.Request) {
DisplayName: displayname,
PreferredName: username,
OnPremisesSamAccountName: username,
UidNumber: uidNumber,
GidNumber: gidNumber,
PasswordProfile: &accounts.PasswordProfile{
Password: password,
},
Expand Down

0 comments on commit def5934

Please sign in to comment.