mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-20 20:08:46 +00:00
* cli core * update material * imports * schematics * lint * rm ng-qrcode, ngx-quicklink * replace qr code lib * rm shared module as quicklink is removed * lazy loading imports * rm public * chore(deps): bump @grpc/grpc-js from 1.7.1 to 1.8.0 in /console (#4857) Bumps [@grpc/grpc-js](https://github.com/grpc/grpc-node) from 1.7.1 to 1.8.0. - [Release notes](https://github.com/grpc/grpc-node/releases) - [Commits](https://github.com/grpc/grpc-node/compare/v1.7.1...@grpc/[email protected]) --- updated-dependencies: - dependency-name: "@grpc/grpc-js" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump libphonenumber-js from 1.10.13 to 1.10.15 in /console (#4861) Bumps [libphonenumber-js](https://gitlab.com/catamphetamine/libphonenumber-js) from 1.10.13 to 1.10.15. - [Release notes](https://gitlab.com/catamphetamine/libphonenumber-js/tags) - [Changelog](https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/CHANGELOG.md) - [Commits](https://gitlab.com/catamphetamine/libphonenumber-js/compare/v1.10.13...v1.10.15) --- updated-dependencies: - dependency-name: libphonenumber-js dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * rxjs * chore(deps): bump engine.io from 6.2.0 to 6.2.1 in /console (#4734) Bumps [engine.io](https://github.com/socketio/engine.io) from 6.2.0 to 6.2.1. - [Release notes](https://github.com/socketio/engine.io/releases) - [Changelog](https://github.com/socketio/engine.io/blob/main/CHANGELOG.md) - [Commits](https://github.com/socketio/engine.io/compare/6.2.0...6.2.1) --- updated-dependencies: - dependency-name: engine.io dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * lock * lint * rm comments * tsconfig ES2022 * get rid of polyfills file * use node 18 * rm age policy, legacy components * packages * build beta prerelease * remove pre-release build Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Florian Forster <[email protected]> Co-authored-by: Livio Spring <[email protected]>
180 lines
6.1 KiB
TypeScript
180 lines
6.1 KiB
TypeScript
import { Component, Injector, Input, OnDestroy, OnInit, Type } from '@angular/core';
|
|
import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog';
|
|
import { Subscription } from 'rxjs';
|
|
import {
|
|
AddCustomDomainPolicyRequest,
|
|
GetCustomOrgIAMPolicyResponse,
|
|
UpdateDomainPolicyRequest,
|
|
} from 'src/app/proto/generated/zitadel/admin_pb';
|
|
import { GetOrgIAMPolicyResponse } from 'src/app/proto/generated/zitadel/management_pb';
|
|
import { Org } from 'src/app/proto/generated/zitadel/org_pb';
|
|
import { DomainPolicy, OrgIAMPolicy } from 'src/app/proto/generated/zitadel/policy_pb';
|
|
import { AdminService } from 'src/app/services/admin.service';
|
|
import { ManagementService } from 'src/app/services/mgmt.service';
|
|
import { StorageLocation, StorageService } from 'src/app/services/storage.service';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
import { WarnDialogComponent } from '../../warn-dialog/warn-dialog.component';
|
|
import { PolicyComponentServiceType } from '../policy-component-types.enum';
|
|
|
|
@Component({
|
|
selector: 'cnsl-domain-policy',
|
|
templateUrl: './domain-policy.component.html',
|
|
styleUrls: ['./domain-policy.component.scss'],
|
|
})
|
|
export class DomainPolicyComponent implements OnInit, OnDestroy {
|
|
private managementService!: ManagementService;
|
|
@Input() public serviceType!: PolicyComponentServiceType;
|
|
|
|
public domainData!: DomainPolicy.AsObject;
|
|
|
|
public loading: boolean = false;
|
|
private sub: Subscription = new Subscription();
|
|
private org!: Org.AsObject;
|
|
|
|
public PolicyComponentServiceType: any = PolicyComponentServiceType;
|
|
|
|
constructor(
|
|
private dialog: MatDialog,
|
|
private toast: ToastService,
|
|
private injector: Injector,
|
|
private adminService: AdminService,
|
|
private storageService: StorageService,
|
|
) {}
|
|
|
|
ngOnInit(): void {
|
|
if (this.serviceType === PolicyComponentServiceType.MGMT) {
|
|
this.managementService = this.injector.get(ManagementService as Type<ManagementService>);
|
|
}
|
|
this.fetchData();
|
|
}
|
|
|
|
public ngOnDestroy(): void {
|
|
this.sub.unsubscribe();
|
|
}
|
|
|
|
public fetchData(): void {
|
|
this.loading = true;
|
|
this.getData()
|
|
.then((resp) => {
|
|
this.loading = false;
|
|
if (resp?.policy) {
|
|
this.domainData = resp.policy;
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
this.loading = false;
|
|
this.toast.showError(error);
|
|
});
|
|
}
|
|
|
|
private async getData(): Promise<GetCustomOrgIAMPolicyResponse.AsObject | GetOrgIAMPolicyResponse.AsObject | any> {
|
|
const org: Org.AsObject | null = this.storageService.getItem('organization', StorageLocation.session);
|
|
|
|
if (org?.id) {
|
|
this.org = org;
|
|
}
|
|
|
|
switch (this.serviceType) {
|
|
case PolicyComponentServiceType.MGMT:
|
|
return this.managementService.getDomainPolicy();
|
|
case PolicyComponentServiceType.ADMIN:
|
|
return this.adminService.getDomainPolicy();
|
|
default:
|
|
return Promise.reject();
|
|
}
|
|
}
|
|
|
|
public savePolicy(): void {
|
|
switch (this.serviceType) {
|
|
case PolicyComponentServiceType.MGMT:
|
|
if ((this.domainData as OrgIAMPolicy.AsObject).isDefault) {
|
|
const req = new AddCustomDomainPolicyRequest();
|
|
req.setOrgId(this.org.id);
|
|
req.setUserLoginMustBeDomain(this.domainData.userLoginMustBeDomain);
|
|
req.setValidateOrgDomains(this.domainData.validateOrgDomains);
|
|
req.setSmtpSenderAddressMatchesInstanceDomain(this.domainData.smtpSenderAddressMatchesInstanceDomain);
|
|
|
|
this.adminService
|
|
.addCustomDomainPolicy(req)
|
|
.then(() => {
|
|
this.toast.showInfo('POLICY.TOAST.SET', true);
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
break;
|
|
} else {
|
|
const req = new AddCustomDomainPolicyRequest();
|
|
req.setOrgId(this.org.id);
|
|
req.setUserLoginMustBeDomain(this.domainData.userLoginMustBeDomain);
|
|
req.setValidateOrgDomains(this.domainData.validateOrgDomains);
|
|
req.setSmtpSenderAddressMatchesInstanceDomain(this.domainData.smtpSenderAddressMatchesInstanceDomain);
|
|
|
|
this.adminService
|
|
.updateCustomDomainPolicy(req)
|
|
.then(() => {
|
|
this.toast.showInfo('POLICY.TOAST.SET', true);
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
break;
|
|
}
|
|
case PolicyComponentServiceType.ADMIN:
|
|
const req = new UpdateDomainPolicyRequest();
|
|
req.setUserLoginMustBeDomain(this.domainData.userLoginMustBeDomain);
|
|
req.setValidateOrgDomains(this.domainData.validateOrgDomains);
|
|
req.setSmtpSenderAddressMatchesInstanceDomain(this.domainData.smtpSenderAddressMatchesInstanceDomain);
|
|
|
|
this.adminService
|
|
.updateDomainPolicy(req)
|
|
.then(() => {
|
|
this.toast.showInfo('POLICY.TOAST.SET', true);
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
break;
|
|
}
|
|
}
|
|
|
|
public removePolicy(): void {
|
|
if (this.serviceType === PolicyComponentServiceType.MGMT) {
|
|
const dialogRef = this.dialog.open(WarnDialogComponent, {
|
|
data: {
|
|
confirmKey: 'ACTIONS.RESET',
|
|
cancelKey: 'ACTIONS.CANCEL',
|
|
titleKey: 'SETTING.DIALOG.RESET.DEFAULTTITLE',
|
|
descriptionKey: 'SETTING.DIALOG.RESET.DEFAULTDESCRIPTION',
|
|
},
|
|
width: '400px',
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe((resp) => {
|
|
if (resp) {
|
|
this.adminService
|
|
.resetCustomDomainPolicyToDefault(this.org.id)
|
|
.then(() => {
|
|
this.toast.showInfo('POLICY.TOAST.RESETSUCCESS', true);
|
|
setTimeout(() => {
|
|
this.fetchData();
|
|
}, 1000);
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
public get isDefault(): boolean {
|
|
if (this.domainData && this.serviceType === PolicyComponentServiceType.MGMT) {
|
|
return (this.domainData as OrgIAMPolicy.AsObject).isDefault;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|