fix: add port to SMTP host label (#4980)

* fix: add port to SMTP host label

* fix gRPC request message

* fix: validate port in backend

* make defaults.yaml host field more clear

* add placeholder smtp host field

* make ipv6 smtp host valid

* hide smtp password input

* fix smtp host not filled

* dont let browsers prefill smtp password
This commit is contained in:
Elio Bischof
2023-01-17 09:20:16 +00:00
committed by GitHub
parent 71bd19d690
commit 0316c2c187
11 changed files with 262 additions and 40 deletions
@@ -27,9 +27,9 @@
{{ 'SETTING.SMTP.TLS' | translate }}
</mat-checkbox>
<cnsl-form-field class="smtp-form-field" label="Host" required="true">
<cnsl-label>{{ 'SETTING.SMTP.HOST' | translate }}</cnsl-label>
<input cnslInput name="host" formControlName="host" />
<cnsl-form-field class="smtp-form-field" label="Host And Port" required="true">
<cnsl-label>{{ 'SETTING.SMTP.HOSTANDPORT' | translate }}</cnsl-label>
<input cnslInput name="hostAndPort" formControlName="hostAndPort" placeholder="smtp.mailtrap.io:2525" />
</cnsl-form-field>
<cnsl-form-field class="smtp-form-field" label="User" required="true">
@@ -59,7 +59,7 @@ export class NotificationSettingsComponent implements OnInit {
senderAddress: [{ disabled: true, value: '' }, [Validators.required]],
senderName: [{ disabled: true, value: '' }, [Validators.required]],
tls: [{ disabled: true, value: true }, [Validators.required]],
host: [{ disabled: true, value: '' }, [Validators.required]],
hostAndPort: [{ disabled: true, value: '' }, [Validators.required]],
user: [{ disabled: true, value: '' }, [Validators.required]],
});
}
@@ -85,6 +85,7 @@ export class NotificationSettingsComponent implements OnInit {
if (smtpConfig.smtpConfig) {
this.hasSMTPConfig = true;
this.form.patchValue(smtpConfig.smtpConfig);
this.form.patchValue({ ['hostAndPort']: smtpConfig.smtpConfig.host });
}
})
.catch((error) => {
@@ -139,7 +140,7 @@ export class NotificationSettingsComponent implements OnInit {
private updateData(): Promise<UpdateSMTPConfigResponse.AsObject | AddSMTPConfigResponse> {
if (this.hasSMTPConfig) {
const req = new UpdateSMTPConfigRequest();
req.setHost(this.host?.value ?? '');
req.setHost(this.hostAndPort?.value ?? '');
req.setSenderAddress(this.senderAddress?.value ?? '');
req.setSenderName(this.senderName?.value ?? '');
req.setTls(this.tls?.value ?? false);
@@ -148,7 +149,7 @@ export class NotificationSettingsComponent implements OnInit {
return this.service.updateSMTPConfig(req);
} else {
const req = new AddSMTPConfigRequest();
req.setHost(this.host?.value ?? '');
req.setHost(this.hostAndPort?.value ?? '');
req.setSenderAddress(this.senderAddress?.value ?? '');
req.setSenderName(this.senderName?.value ?? '');
req.setTls(this.tls?.value ?? false);
@@ -305,7 +306,7 @@ export class NotificationSettingsComponent implements OnInit {
return this.form.get('user');
}
public get host(): AbstractControl | null {
return this.form.get('host');
public get hostAndPort(): AbstractControl | null {
return this.form.get('hostAndPort');
}
}
@@ -4,7 +4,7 @@
<div mat-dialog-content>
<cnsl-form-field class="formfield">
<cnsl-label>{{ data.i18nLabel | translate }}</cnsl-label>
<input cnslInput [(ngModel)]="password" />
<input cnslInput [(ngModel)]="password" type="password" autocomplete="new-password" />
</cnsl-form-field>
</div>
<div mat-dialog-actions class="action">