Skip to content

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

Fix minor inconsistencies in settings.

Kailash Nadh7ed07550ff45
diff --git a/frontend/src/views/Settings.vue b/frontend/src/views/Settings.vue
index e46e43df..2608a547 100644
--- a/frontend/src/views/Settings.vue
+++ b/frontend/src/views/Settings.vue
@@ -177,7 +177,8 @@
<b-input v-model="form['upload.s3.aws_access_key_id']"
name="upload.s3.aws_access_key_id" :maxlength="200" />
</b-field>
- <b-field label="AWS access secret" label-position="on-border" expanded>
+ <b-field label="AWS access secret" label-position="on-border" expanded
+ message="Enter a value to change.">
<b-input v-model="form['upload.s3.aws_secret_access_key']"
name="upload.s3.aws_secret_access_key" type="password"
:maxlength="200" />
@@ -281,7 +282,7 @@
name="username" placeholder="mysmtp" :maxlength="200" />
</b-field>
<b-field label="Password" label-position="on-border" expanded
- message="Enter a value to change. Otherwise, leave empty.">
+ message="Enter a value to change.">
<b-input v-model="item.password"
:disabled="item.auth_protocol === 'none'"
name="password" type="password" placeholder="Enter to change"
@@ -389,6 +390,8 @@ import { mapState } from 'vuex';
import store from '../store';
import { models } from '../constants';
+const dummyPassword = ' '.repeat(8);
+
export default Vue.extend({
data() {
return {
@@ -419,10 +422,15 @@ export default Vue.extend({
},
onSubmit() {
- const form = { ...this.form };
+ const form = JSON.parse(JSON.stringify(this.form));
// De-serialize custom e-mail headers.
for (let i = 0; i < form.smtp.length; i += 1) {
+ // If it's the dummy UI password placeholder, ignore it.
+ if (form.smtp[i].password === dummyPassword) {
+ form.smtp[i].password = '';
+ }
+
if (form.smtp[i].strEmailHeaders && form.smtp[i].strEmailHeaders !== '[]') {
form.smtp[i].email_headers = JSON.parse(form.smtp[i].strEmailHeaders);
} else {
@@ -430,8 +438,12 @@ export default Vue.extend({
}
}
+ if (form['upload.s3.aws_secret_access_key'] === dummyPassword) {
+ form['upload.s3.aws_secret_access_key'] = '';
+ }
+
this.isLoading = true;
- this.$api.updateSettings(this.form).then((data) => {
+ this.$api.updateSettings(form).then((data) => {
if (data.needsRestart) {
// Update the 'needsRestart' flag on the global serverConfig state
// as there are running campaigns and the app couldn't auto-restart.
@@ -462,6 +474,14 @@ export default Vue.extend({
// Serialize the `email_headers` array map to display on the form.
for (let i = 0; i < d.smtp.length; i += 1) {
d.smtp[i].strEmailHeaders = JSON.stringify(d.smtp[i].email_headers, null, 4);
+
+ // The backend doesn't send passwords, so add a dummy so that it
+ // the password looks filled on the UI.
+ d.smtp[i].password = dummyPassword;
+ }
+
+ if (d['upload.provider'] === 's3') {
+ d['upload.s3.aws_secret_access_key'] = dummyPassword;
}
this.form = d;
diff --git a/handlers.go b/handlers.go
index fd84c9a4..67908ba3 100644
--- a/handlers.go
+++ b/handlers.go
@@ -124,6 +124,7 @@ func registerHTTPHandlers(e *echo.Echo) {
e.GET("/campaigns/media", handleIndexPage)
e.GET("/campaigns/templates", handleIndexPage)
e.GET("/campaigns/:campignID", handleIndexPage)
+ e.GET("/settings", handleIndexPage)
}
// handleIndex is the root handler that renders the Javascript frontend.
diff --git a/internal/migrations/v0.7.0.go b/internal/migrations/v0.7.0.go
index 2d484cff..871ac15d 100644
--- a/internal/migrations/v0.7.0.go
+++ b/internal/migrations/v0.7.0.go
@@ -66,6 +66,7 @@ func V0_7_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {
-- Insert default settings if the table is empty.
INSERT INTO settings (key, value) SELECT k, v::JSONB FROM (VALUES
+ ('app.root_url', '"http://localhost:9000"'),
('app.favicon_url', '""'),
('app.from_email', '"listmonk <[email protected]>"'),
('app.logo_url', '"http://localhost:9000/public/static/logo.png"'),
diff --git a/queries.sql b/queries.sql
index 62ef264a..2ee40f5a 100644
--- a/queries.sql
+++ b/queries.sql
@@ -733,5 +733,5 @@ SELECT JSON_OBJECT_AGG(key, value) AS settings
-- name: update-settings
UPDATE settings AS s SET value = c.value
- -- For each key in the incoming JSON map, update the row with the key and it's value.
+ -- For each key in the incoming JSON map, update the row with the key and its value.
FROM(SELECT * FROM JSONB_EACH($1)) AS c(key, value) WHERE s.key = c.key;
diff --git a/settings.go b/settings.go
index 16666619..24ad4d87 100644
--- a/settings.go
+++ b/settings.go
@@ -117,7 +117,7 @@ func handleUpdateSettings(c echo.Context) error {
}
if !has {
return echo.NewHTTPError(http.StatusBadRequest,
- "At least one SMTP block should be enabled")
+ "Minimum one SMTP block should be enabled.")
}
// S3 password?