Skip to content

Commit

Permalink
fix: check for one primary email
Browse files Browse the repository at this point in the history
only create a user through the admin API when emails are set and one of them is marked as primary
  • Loading branch information
FreddyDevelop committed Aug 26, 2024
1 parent af5b37b commit 3471da6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/handler/user_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ func (h *UserHandlerAdmin) Create(c echo.Context) error {
}
}

if primaryEmails > 1 {
if primaryEmails == 0 && len(body.Emails) > 0 {
return echo.NewHTTPError(http.StatusBadRequest, "at least one primary email must be provided")
} else if primaryEmails > 1 {
return echo.NewHTTPError(http.StatusBadRequest, "only one primary email is allowed")
}

Expand Down

0 comments on commit 3471da6

Please sign in to comment.