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

Commit

Permalink
Merge pull request #31 from owncloud/fix-30
Browse files Browse the repository at this point in the history
Validation on adding user to group
  • Loading branch information
Vincent Petry authored Aug 6, 2020
2 parents 886f75d + 0db046d commit 43514cd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/service/v0/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ func (o Ocs) ListUserGroups(w http.ResponseWriter, r *http.Request) {

// AddToGroup adds a user to a group
func (o Ocs) AddToGroup(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
userid := chi.URLParam(r, "userid")
groupid := r.URL.Query().Get("groupid")
groupid := r.PostForm.Get("groupid")

if groupid == "" {
render.Render(w, r, response.ErrRender(data.MetaBadRequest.StatusCode, "empty group assignment: unspecified group"))
return
}

_, err := o.getGroupsService().AddMember(r.Context(), &accounts.AddMemberRequest{
AccountId: userid,
Expand Down

0 comments on commit 43514cd

Please sign in to comment.