Skip to content

Commit

Permalink
Return user type in the response of the ocs GET user call
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Nov 10, 2021
1 parent 63cd968 commit 4cc6eef
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/ocs-user-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Return user type in the response of the ocs GET user call

https://github.com/cs3org/reva/pull/2256
23 changes: 23 additions & 0 deletions internal/http/services/owncloud/ocs/handlers/cloud/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"net/http"

userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
"github.com/cs3org/reva/internal/http/services/owncloud/ocs/response"
ctxpkg "github.com/cs3org/reva/pkg/ctx"
)
Expand All @@ -45,6 +46,7 @@ func (h *Handler) GetSelf(w http.ResponseWriter, r *http.Request) {
ID: u.Username,
DisplayName: u.DisplayName,
Email: u.Mail,
UserType: userTypeString(u.Id.Type),
})
}

Expand All @@ -54,4 +56,25 @@ type User struct {
ID string `json:"id" xml:"id"`
DisplayName string `json:"display-name" xml:"display-name"`
Email string `json:"email" xml:"email"`
UserType string `json:"user-type" xml:"user-type"`
}

func userTypeString(userType userv1beta1.UserType) string {
switch userType {
case userv1beta1.UserType_USER_TYPE_PRIMARY:
return "primary"
case userv1beta1.UserType_USER_TYPE_SECONDARY:
return "secondary"
case userv1beta1.UserType_USER_TYPE_SERVICE:
return "service"
case userv1beta1.UserType_USER_TYPE_APPLICATION:
return "application"
case userv1beta1.UserType_USER_TYPE_GUEST:
return "guest"
case userv1beta1.UserType_USER_TYPE_FEDERATED:
return "federated"
case userv1beta1.UserType_USER_TYPE_LIGHTWEIGHT:
return "lightweight"
}
return "invalid"
}

0 comments on commit 4cc6eef

Please sign in to comment.