From 02c5d39a05ca0dc34f949bd5be062b5c8ee3f6dd Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 12 Feb 2025 10:29:12 +0530 Subject: [PATCH] feat: only send password from the frontend if it has changed --- .../routes/dashboard/settings/inbox/ImapSettings.vue | 8 +++++++- .../routes/dashboard/settings/inbox/SmtpSettings.vue | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/ImapSettings.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/ImapSettings.vue index fdb0173e0..d096435e6 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/ImapSettings.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/ImapSettings.vue @@ -65,6 +65,7 @@ export default { async updateInbox() { try { this.loading = true; + let payload = { id: this.inbox.id, formData: false, @@ -73,11 +74,16 @@ export default { imap_address: this.address, imap_port: this.port, imap_login: this.login, - imap_password: this.password, imap_enable_ssl: this.isSSLEnabled, }, }; + // If the password is a placeholder, don't send it to the server + const isPlaceholderPassword = /^\*+$/.test(this.password); + if (!isPlaceholderPassword) { + payload.channel.imap_password = this.password; + } + if (!this.isIMAPEnabled) { payload.channel.smtp_enabled = false; } diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/SmtpSettings.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/SmtpSettings.vue index 0ec61f266..94f0f3184 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/SmtpSettings.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/SmtpSettings.vue @@ -134,7 +134,6 @@ export default { smtp_address: this.address, smtp_port: this.port, smtp_login: this.login, - smtp_password: this.password, smtp_domain: this.domain, smtp_enable_ssl_tls: this.ssl, smtp_enable_starttls_auto: this.starttls, @@ -142,6 +141,12 @@ export default { smtp_authentication: this.authMechanism, }, }; + + const isPlaceholderPassword = /^\*+$/.test(this.password); + if (!isPlaceholderPassword) { + payload.channel.smtp_password = this.password; + } + await this.$store.dispatch('inboxes/updateInboxSMTP', payload); useAlert(this.$t('INBOX_MGMT.SMTP.EDIT.SUCCESS_MESSAGE')); } catch (error) {