Skip to content

Commit

Permalink
Merge pull request #3376 from rhafer/graph-user-patch
Browse files Browse the repository at this point in the history
graph: Allow PATCH on user without 'mail' in body
  • Loading branch information
rhafer authored Mar 29, 2022
2 parents c34503e + 517356f commit ec0b3b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/graph-patch-mail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix request validation on GraphAPI User updates

Fix PATCH on graph/v1.0/users when no 'mail' attribute
is present in the request body

https://github.com/owncloud/ocis/issues/3167
11 changes: 6 additions & 5 deletions graph/pkg/service/v0/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ func (g Graph) PatchUser(w http.ResponseWriter, r *http.Request) {
return
}

mail := changes.GetMail()
if !isValidEmail(mail) {
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
fmt.Sprintf("'%s' is not a valid email address", mail))
return
if mail, ok := changes.GetMailOk(); ok {
if !isValidEmail(*mail) {
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
fmt.Sprintf("'%s' is not a valid email address", *mail))
return
}
}

u, err := g.identityBackend.UpdateUser(r.Context(), nameOrID, *changes)
Expand Down

0 comments on commit ec0b3b1

Please sign in to comment.