feat: only send password from the frontend if it has changed

This commit is contained in:
Shivam Mishra
2025-02-12 10:29:12 +05:30
parent 6a2f4d8248
commit 02c5d39a05
2 changed files with 13 additions and 2 deletions
@@ -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;
}
@@ -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) {