Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Throw an error if there isn't a single permitted list in subscriber create/update. Closes #2905.

Kailash Nadhee7bccc746db
diff --git a/cmd/subscribers.go b/cmd/subscribers.go
index c8883c3e..80d88c84 100644
--- a/cmd/subscribers.go
+++ b/cmd/subscribers.go
@@ -235,6 +235,11 @@ func (a *App) CreateSubscriber(c echo.Context) error {
// Filter lists against the current user's permitted lists.
listIDs := user.FilterListsByPerm(auth.PermTypeManage, req.Lists)
+ // Not a single permitted list?
+ if len(req.Lists) > 0 && len(listIDs) == 0 {
+ return echo.NewHTTPError(http.StatusForbidden, a.i18n.Ts("globals.messages.permissionDenied", "name", "lists"))
+ }
+
// Insert the subscriber into the DB.
sub, _, err := a.core.InsertSubscriber(req.Subscriber, listIDs, nil, req.PreconfirmSubs, false)
if err != nil {
@@ -273,6 +278,11 @@ func (a *App) UpdateSubscriber(c echo.Context) error {
// Filter lists against the current user's permitted lists.
listIDs := user.FilterListsByPerm(auth.PermTypeManage, req.Lists)
+ // Not a single permitted list?
+ if len(req.Lists) > 0 && len(listIDs) == 0 {
+ return echo.NewHTTPError(http.StatusForbidden, a.i18n.Ts("globals.messages.permissionDenied", "name", "lists"))
+ }
+
// Update the subscriber in the DB.
id := getID(c)
out, _, err := a.core.UpdateSubscriberWithLists(id, req.Subscriber, listIDs, nil, req.PreconfirmSubs, true, false)
@@ -371,8 +381,7 @@ func (a *App) ManageSubscriberLists(c echo.Context) error {
// User doesn't have the required list permissions.
if len(listIDs) == 0 {
- return echo.NewHTTPError(http.StatusForbidden,
- a.i18n.Ts("globals.messages.permissionDenied", "name", "lists"))
+ return echo.NewHTTPError(http.StatusForbidden, a.i18n.Ts("globals.messages.permissionDenied", "name", "lists"))
}
// Run the action in the DB.