Skip to content

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

Fix users without certain list permissions being able to see list names on subs.

Kailash Nadh86c94c80d2bf
diff --git a/cmd/subscribers.go b/cmd/subscribers.go
index 9bb1546d..13a1272a 100644
--- a/cmd/subscribers.go
+++ b/cmd/subscribers.go
@@ -71,6 +71,8 @@ func (a *App) GetSubscriber(c echo.Context) error {
return err
}
+ maskRestrictedSubLists(user, &out)
+
return c.JSON(http.StatusOK, okResp{out})
}
@@ -127,6 +129,10 @@ func (a *App) QuerySubscribers(c echo.Context) error {
return err
}
+ for i := range res {
+ maskRestrictedSubLists(user, &res[i])
+ }
+
out := models.PageResults{
Query: query,
Search: searchStr,
@@ -298,6 +304,8 @@ func (a *App) UpdateSubscriber(c echo.Context) error {
return err
}
+ maskRestrictedSubLists(user, &out)
+
return c.JSON(http.StatusOK, okResp{out})
}
@@ -359,6 +367,8 @@ func (a *App) PatchSubscriber(c echo.Context) error {
return err
}
+ maskRestrictedSubLists(user, &out)
+
return c.JSON(http.StatusOK, okResp{out})
}
@@ -741,6 +751,34 @@ func (a *App) exportSubscriberData(id int, subUUID string, exportables map[strin
return data, b, nil
}
+// maskRestrictedSubLists replaces list names with "*Unknown" for lists
+// the user doesn't have manage permission on. This appears on the subscriber
+// details UI and prevents users without access to certain lists from seeing their names.
+func maskRestrictedSubLists(user auth.User, sub *models.Subscriber) {
+ if user.HasPerm(auth.PermListManageAll) {
+ return
+ }
+
+ // Hacky JSON manipulation (for now).
+ var lists []map[string]interface{}
+ if err := json.Unmarshal(sub.Lists, &lists); err != nil || len(lists) == 0 {
+ return
+ }
+
+ for i, l := range lists {
+ id, _ := l["id"].(float64)
+ if user.HasListPerm(auth.PermTypeManage, int(id)) != nil {
+ lists[i]["name"] = "*Unknown"
+ lists[i]["restricted"] = true
+ delete(lists[i], "description")
+ }
+ }
+
+ if b, err := json.Marshal(lists); err == nil {
+ sub.Lists = b
+ }
+}
+
// hasSubPerm checks whether the current user has permission to access the given list
// of subscriber IDs.
func (a *App) hasSubPerm(u auth.User, subIDs []int) error {
diff --git a/frontend/src/assets/style.scss b/frontend/src/assets/style.scss
index 2b116d07..ae032f1b 100644
--- a/frontend/src/assets/style.scss
+++ b/frontend/src/assets/style.scss
@@ -817,6 +817,11 @@ section.lists {
/* List selector */
.list-tags {
margin-bottom: 1rem;
+
+ .is-restricted {
+ opacity: 0.6;
+ font-style: italic;
+ }
}
/* Subscribers page */
diff --git a/frontend/src/components/ListSelector.vue b/frontend/src/components/ListSelector.vue
index 53610cae..c3c0479f 100644
--- a/frontend/src/components/ListSelector.vue
+++ b/frontend/src/components/ListSelector.vue
@@ -2,8 +2,8 @@
<div class="field list-selector">
<div :class="['list-tags', ...classes]">
<b-taglist>
- <b-tag v-for="l in selectedItems" :key="l.id" :class="l.subscriptionStatus" :closable="!$props.disabled"
- :data-id="l.id" @close="removeList(l.id)" class="list">
+ <b-tag v-for="l in selectedItems" :key="l.id" :class="[l.subscriptionStatus, { 'is-restricted': l.restricted }]"
+ :closable="!$props.disabled && !l.restricted" :data-id="l.id" @close="removeList(l.id)" class="list">
{{ l.name }}
<sup v-if="l.optin === 'double' && l.subscriptionStatus">
{{ $t(`subscribers.status.${l.subscriptionStatus}`) }}
diff --git a/frontend/src/views/SubscriberForm.vue b/frontend/src/views/SubscriberForm.vue
index bb00e408..e9a08738 100644
--- a/frontend/src/views/SubscriberForm.vue
+++ b/frontend/src/views/SubscriberForm.vue
@@ -72,9 +72,10 @@
<b-table :data="data.lists" hoverable default-sort="createdAt" class="subscriptions">
<b-table-column v-slot="props" field="name" :label="$tc('globals.terms.list', 1)">
<div>
- <router-link :to="`/lists/${props.row.id}`">
+ <router-link v-if="!props.row.restricted" :to="`/lists/${props.row.id}`">
{{ props.row.name }}
</router-link>
+ <span v-else class="has-text-grey-light is-italic">{{ props.row.name }}</span>
<br />
<b-tag :class="props.row.optin" :data-cy="`optin-${props.row.optin}`">
<b-icon :icon="props.row.optin === 'double' ? 'account-check-outline' : 'account-off-outline'"