fix: SMTP config setup (#4272)

* fix: change default for SMTPSenderAddressMatchesInstanceDomain to false

* fix: handle error in console
This commit is contained in:
Livio Spring 2022-09-02 09:04:29 +02:00 committed by GitHub
parent 05f918ac83
commit bee616c11a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 27 deletions

View File

@ -361,7 +361,7 @@ DefaultInstance:
DomainPolicy: DomainPolicy:
UserLoginMustBeDomain: true UserLoginMustBeDomain: true
ValidateOrgDomains: true ValidateOrgDomains: true
SMTPSenderAddressMatchesInstanceDomain: true SMTPSenderAddressMatchesInstanceDomain: false
LoginPolicy: LoginPolicy:
AllowUsernamePassword: true AllowUsernamePassword: true
AllowRegister: true AllowRegister: true

View File

@ -3,12 +3,14 @@ import { AbstractControl, UntypedFormBuilder, UntypedFormGroup, Validators } fro
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { take } from 'rxjs'; import { take } from 'rxjs';
import { import {
AddSMSProviderTwilioRequest, AddSMSProviderTwilioRequest,
AddSMTPConfigRequest, AddSMTPConfigRequest,
UpdateSMSProviderTwilioRequest, AddSMTPConfigResponse,
UpdateSMTPConfigPasswordRequest, UpdateSMSProviderTwilioRequest,
UpdateSMTPConfigPasswordResponse, UpdateSMTPConfigPasswordRequest,
UpdateSMTPConfigRequest, UpdateSMTPConfigPasswordResponse,
UpdateSMTPConfigRequest,
UpdateSMTPConfigResponse,
} from 'src/app/proto/generated/zitadel/admin_pb'; } from 'src/app/proto/generated/zitadel/admin_pb';
import { DebugNotificationProvider, SMSProvider, SMSProviderConfigState } from 'src/app/proto/generated/zitadel/settings_pb'; import { DebugNotificationProvider, SMSProvider, SMSProviderConfigState } from 'src/app/proto/generated/zitadel/settings_pb';
import { AdminService } from 'src/app/services/admin.service'; import { AdminService } from 'src/app/services/admin.service';
@ -134,7 +136,7 @@ export class NotificationSettingsComponent implements OnInit {
}); });
} }
private updateData(): Promise<UpdateSMTPConfigPasswordResponse.AsObject> | any { private updateData(): Promise<UpdateSMTPConfigResponse.AsObject | AddSMTPConfigResponse> {
if (this.hasSMTPConfig) { if (this.hasSMTPConfig) {
const req = new UpdateSMTPConfigRequest(); const req = new UpdateSMTPConfigRequest();
req.setHost(this.host?.value ?? ''); req.setHost(this.host?.value ?? '');
@ -143,9 +145,7 @@ export class NotificationSettingsComponent implements OnInit {
req.setTls(this.tls?.value ?? false); req.setTls(this.tls?.value ?? false);
req.setUser(this.user?.value ?? ''); req.setUser(this.user?.value ?? '');
return this.service.updateSMTPConfig(req).catch((error) => { return this.service.updateSMTPConfig(req);
this.toast.showError(error);
});
} else { } else {
const req = new AddSMTPConfigRequest(); const req = new AddSMTPConfigRequest();
req.setHost(this.host?.value ?? ''); req.setHost(this.host?.value ?? '');
@ -154,26 +154,21 @@ export class NotificationSettingsComponent implements OnInit {
req.setTls(this.tls?.value ?? false); req.setTls(this.tls?.value ?? false);
req.setUser(this.user?.value ?? ''); req.setUser(this.user?.value ?? '');
return this.service.addSMTPConfig(req).catch((error) => { return this.service.addSMTPConfig(req);
this.toast.showError(error);
});
} }
} }
public savePolicy(): void { public savePolicy(): void {
const prom = this.updateData(); this.updateData()
if (prom) { .then(() => {
prom this.toast.showInfo('SETTING.SMTP.SAVED', true);
.then(() => { setTimeout(() => {
this.toast.showInfo('SETTING.SMTP.SAVED', true); this.fetchData();
setTimeout(() => { }, 2000);
this.fetchData(); })
}, 2000); .catch((error: unknown) => {
}) this.toast.showError(error);
.catch((error: unknown) => { });
this.toast.showError(error);
});
}
} }
public editSMSProvider(): void { public editSMSProvider(): void {