diff --git a/console/src/app/modules/idp-table/idp-table.component.ts b/console/src/app/modules/idp-table/idp-table.component.ts index 0d352a0be..d7d1288ba 100644 --- a/console/src/app/modules/idp-table/idp-table.component.ts +++ b/console/src/app/modules/idp-table/idp-table.component.ts @@ -226,6 +226,7 @@ export class IdpTableComponent implements OnInit { switch (this.serviceType) { case PolicyComponentServiceType.MGMT: return (this.service as ManagementService).addIDPToLoginPolicy(idp.id, idp.owner).then(() => { + this.toast.showInfo('IDP.TOAST.ADDED', true); this.getIdps() .then((resp) => { this.idps = resp; @@ -238,6 +239,7 @@ export class IdpTableComponent implements OnInit { return (this.service as AdminService) .addIDPToLoginPolicy(idp.id) .then(() => { + this.toast.showInfo('IDP.TOAST.ADDED', true); this.getIdps().then((resp) => { this.idps = resp; }); @@ -251,28 +253,30 @@ export class IdpTableComponent implements OnInit { public removeIdp(idp: IDP.AsObject): void { switch (this.serviceType) { case PolicyComponentServiceType.MGMT: - (this.service as ManagementService).removeIDPFromLoginPolicy(idp.id).then( - () => { + (this.service as ManagementService) + .removeIDPFromLoginPolicy(idp.id) + .then(() => { + this.toast.showInfo('IDP.TOAST.REMOVED', true); this.getIdps().then((resp) => { this.idps = resp; }); - }, - (error) => { + }) + .catch((error) => { this.toast.showError(error); - }, - ); + }); break; case PolicyComponentServiceType.ADMIN: - (this.service as AdminService).removeIDPFromLoginPolicy(idp.id).then( - () => { + (this.service as AdminService) + .removeIDPFromLoginPolicy(idp.id) + .then(() => { + this.toast.showInfo('IDP.TOAST.REMOVED', true); this.getIdps().then((resp) => { this.idps = resp; }); - }, - (error) => { + }) + .catch((error) => { this.toast.showError(error); - }, - ); + }); break; } } diff --git a/console/src/app/modules/policies/login-policy/factor-table/factor-table.component.ts b/console/src/app/modules/policies/login-policy/factor-table/factor-table.component.ts index 08c5b057c..7e933d4da 100644 --- a/console/src/app/modules/policies/login-policy/factor-table/factor-table.component.ts +++ b/console/src/app/modules/policies/login-policy/factor-table/factor-table.component.ts @@ -41,7 +41,9 @@ export class FactorTableComponent { @Input() service!: AdminService | ManagementService; @Input() disabled: boolean = false; @Input() list: Array = []; - @Output() listChanged: EventEmitter = new EventEmitter(); + @Output() typeRemoved: EventEmitter> = new EventEmitter(); + @Output() typeAdded: EventEmitter> = new EventEmitter(); + @ViewChild(MatPaginator) public paginator!: MatPaginator; private loadingSubject: BehaviorSubject = new BehaviorSubject(false); @@ -64,59 +66,33 @@ export class FactorTableComponent { dialogRef.afterClosed().subscribe((resp) => { if (resp) { + let request; + if (this.serviceType === PolicyComponentServiceType.MGMT) { if (this.componentType === LoginMethodComponentType.MultiFactor) { const req = new MgmtRemoveMultiFactorFromLoginPolicyRequest(); req.setType(type as MultiFactorType); - (this.service as ManagementService) - .removeMultiFactorFromLoginPolicy(req) - .then(() => { - this.toast.showInfo('MFA.TOAST.DELETED', true); - this.listChanged.emit(); - }) - .catch((error) => { - this.toast.showError(error); - }); + request = (this.service as ManagementService).removeMultiFactorFromLoginPolicy(req); } else if (this.componentType === LoginMethodComponentType.SecondFactor) { const req = new MgmtRemoveSecondFactorFromLoginPolicyRequest(); req.setType(type as SecondFactorType); - (this.service as ManagementService) - .removeSecondFactorFromLoginPolicy(req) - .then(() => { - this.toast.showInfo('MFA.TOAST.DELETED', true); - this.listChanged.emit(); - }) - .catch((error) => { - this.toast.showError(error); - }); + request = (this.service as ManagementService).removeSecondFactorFromLoginPolicy(req); } } else if (this.serviceType === PolicyComponentServiceType.ADMIN) { if (this.componentType === LoginMethodComponentType.MultiFactor) { const req = new AdminRemoveMultiFactorFromLoginPolicyRequest(); req.setType(type as MultiFactorType); - (this.service as AdminService) - .removeMultiFactorFromLoginPolicy(req) - .then(() => { - this.toast.showInfo('MFA.TOAST.DELETED', true); - this.listChanged.emit(); - }) - .catch((error) => { - this.toast.showError(error); - }); + request = (this.service as AdminService).removeMultiFactorFromLoginPolicy(req); } else if (this.componentType === LoginMethodComponentType.SecondFactor) { const req = new AdminRemoveSecondFactorFromLoginPolicyRequest(); req.setType(type as SecondFactorType); - (this.service as AdminService) - .removeSecondFactorFromLoginPolicy(req) - .then(() => { - this.toast.showInfo('MFA.TOAST.DELETED', true); - this.listChanged.emit(); - }) - .catch((error) => { - this.toast.showError(error); - }); + request = (this.service as AdminService).removeSecondFactorFromLoginPolicy(req); } } + + if (request) { + this.typeRemoved.emit(request); + } } }); } @@ -134,59 +110,33 @@ export class FactorTableComponent { dialogRef.afterClosed().subscribe((mfaType: MultiFactorType | SecondFactorType) => { if (mfaType) { + let request; + if (this.serviceType === PolicyComponentServiceType.MGMT) { if (this.componentType === LoginMethodComponentType.MultiFactor) { const req = new MgmtAddMultiFactorToLoginPolicyRequest(); req.setType(mfaType as MultiFactorType); - (this.service as ManagementService) - .addMultiFactorToLoginPolicy(req) - .then(() => { - this.toast.showInfo('MFA.TOAST.ADDED', true); - this.listChanged.emit(); - }) - .catch((error) => { - this.toast.showError(error); - }); + request = (this.service as ManagementService).addMultiFactorToLoginPolicy(req); } else if (this.componentType === LoginMethodComponentType.SecondFactor) { const req = new MgmtAddSecondFactorToLoginPolicyRequest(); req.setType(mfaType as SecondFactorType); - (this.service as ManagementService) - .addSecondFactorToLoginPolicy(req) - .then(() => { - this.toast.showInfo('MFA.TOAST.ADDED', true); - this.listChanged.emit(); - }) - .catch((error) => { - this.toast.showError(error); - }); + request = (this.service as ManagementService).addSecondFactorToLoginPolicy(req); } } else if (this.serviceType === PolicyComponentServiceType.ADMIN) { if (this.componentType === LoginMethodComponentType.MultiFactor) { const req = new AdminAddMultiFactorToLoginPolicyRequest(); req.setType(mfaType as MultiFactorType); - (this.service as AdminService) - .addMultiFactorToLoginPolicy(req) - .then(() => { - this.toast.showInfo('MFA.TOAST.ADDED', true); - this.listChanged.emit(); - }) - .catch((error) => { - this.toast.showError(error); - }); + request = (this.service as AdminService).addMultiFactorToLoginPolicy(req); } else if (this.componentType === LoginMethodComponentType.SecondFactor) { const req = new AdminAddSecondFactorToLoginPolicyRequest(); req.setType(mfaType as SecondFactorType); - (this.service as AdminService) - .addSecondFactorToLoginPolicy(req) - .then(() => { - this.toast.showInfo('MFA.TOAST.ADDED', true); - this.listChanged.emit(); - }) - .catch((error) => { - this.toast.showError(error); - }); + request = (this.service as AdminService).addSecondFactorToLoginPolicy(req); } } + + if (request) { + this.typeAdded.emit(request); + } } }); } diff --git a/console/src/app/modules/policies/login-policy/login-policy.component.html b/console/src/app/modules/policies/login-policy/login-policy.component.html index 9a2cbe427..1b1ec2216 100644 --- a/console/src/app/modules/policies/login-policy/login-policy.component.html +++ b/console/src/app/modules/policies/login-policy/login-policy.component.html @@ -56,7 +56,8 @@ [serviceType]="serviceType" [componentType]="LoginMethodComponentType.MultiFactor" [list]="loginData.multiFactorsList" - (listChanged)="fetchData()" + (typeRemoved)="removeFactor($event)" + (typeAdded)="addFactor($event)" [disabled]=" loginData?.passwordlessType === PasswordlessType.PASSWORDLESS_TYPE_NOT_ALLOWED || ([ @@ -106,7 +107,8 @@ [serviceType]="serviceType" [componentType]="LoginMethodComponentType.SecondFactor" [list]="loginData.secondFactorsList" - (listChanged)="fetchData()" + (typeRemoved)="removeFactor($event)" + (typeAdded)="addFactor($event)" [disabled]=" ([ serviceType === PolicyComponentServiceType.ADMIN diff --git a/console/src/app/modules/policies/login-policy/login-policy.component.ts b/console/src/app/modules/policies/login-policy/login-policy.component.ts index dc706190d..eed4340cd 100644 --- a/console/src/app/modules/policies/login-policy/login-policy.component.ts +++ b/console/src/app/modules/policies/login-policy/login-policy.component.ts @@ -94,7 +94,9 @@ export class LoginPolicyComponent implements OnInit { ); } }) - .catch(this.toast.showError); + .catch((error) => { + this.toast.showError(error); + }); } public ngOnInit(): void { @@ -171,10 +173,7 @@ export class LoginPolicyComponent implements OnInit { mgmtreq.setIgnoreUnknownUsernames(this.loginData.ignoreUnknownUsernames); mgmtreq.setDefaultRedirectUri(this.loginData.defaultRedirectUri); - // if(this.loginData.passwordCheckLifetime) { - // mgmtreq.setPasswordCheckLifetime(this.loginData.passwordCheckLifetime); - // } - if ((this.loginData as LoginPolicy.AsObject).isDefault) { + if (this.isDefault) { return (this.service as ManagementService).addCustomLoginPolicy(mgmtreq); } else { return (this.service as ManagementService).updateCustomLoginPolicy(mgmtreq); @@ -204,7 +203,6 @@ export class LoginPolicyComponent implements OnInit { adminreq.setMultiFactorCheckLifetime(admin_mficl); adminreq.setIgnoreUnknownUsernames(this.loginData.ignoreUnknownUsernames); adminreq.setDefaultRedirectUri(this.loginData.defaultRedirectUri); - // adminreq.setPasswordCheckLifetime(this.loginData.passwordCheckLifetime); return (this.service as AdminService).updateLoginPolicy(adminreq); } @@ -256,6 +254,57 @@ export class LoginPolicyComponent implements OnInit { } } + public removeFactor(request: Promise): void { + // create policy before types can be removed + if (this.isDefault) { + console.log('create policy'); + this.updateData() + .then(() => { + return request; + }) + .then(() => { + this.toast.showInfo('MFA.TOAST.DELETED', true); + setTimeout(() => { + this.fetchData(); + }, 2000); + }) + .catch((error) => { + this.toast.showError(error); + }); + } else { + request + .then(() => { + this.toast.showInfo('MFA.TOAST.DELETED', true); + setTimeout(() => { + this.fetchData(); + }, 2000); + }) + .catch((error) => { + this.toast.showError(error); + }); + } + } + + public addFactor(request: Promise): void { + // create policy before types can be added + const task: Promise = this.isDefault + ? this.updateData().then(() => { + return request; + }) + : request; + + task + .then(() => { + this.toast.showInfo('MFA.TOAST.ADDED', true); + setTimeout(() => { + this.fetchData(); + }, 2000); + }) + .catch((error) => { + this.toast.showError(error); + }); + } + public get isDefault(): boolean { if (this.loginData && this.serviceType === PolicyComponentServiceType.MGMT) { return (this.loginData as LoginPolicy.AsObject).isDefault; diff --git a/console/src/app/pages/projects/owned-projects/project-grant-detail/project-grant-detail.component.ts b/console/src/app/pages/projects/owned-projects/project-grant-detail/project-grant-detail.component.ts index 70f567a0a..13d0d10cb 100644 --- a/console/src/app/pages/projects/owned-projects/project-grant-detail/project-grant-detail.component.ts +++ b/console/src/app/pages/projects/owned-projects/project-grant-detail/project-grant-detail.component.ts @@ -89,7 +89,9 @@ export class ProjectGrantDetailComponent { this.breadcrumbService.setBreadcrumb(breadcrumbs); } }) - .catch(this.toast.showError); + .catch((error) => { + this.toast.showError(error); + }); }); } diff --git a/console/src/app/services/asset.service.ts b/console/src/app/services/asset.service.ts index 4a3bf61a1..25e6ba1df 100644 --- a/console/src/app/services/asset.service.ts +++ b/console/src/app/services/asset.service.ts @@ -18,23 +18,23 @@ export enum AssetType { } export enum AssetEndpoint { - IAMFONT = 'iam/policy/label/font', + IAMFONT = 'instance/policy/label/font', MGMTFONT = 'org/policy/label/font', - IAMDARKLOGO = 'iam/policy/label/logo/dark', - IAMLOGO = 'iam/policy/label/logo', - IAMDARKICON = 'iam/policy/label/icon/dark', - IAMICON = 'iam/policy/label/icon', + IAMDARKLOGO = 'instance/policy/label/logo/dark', + IAMLOGO = 'instance/policy/label/logo', + IAMDARKICON = 'instance/policy/label/icon/dark', + IAMICON = 'instance/policy/label/icon', MGMTDARKLOGO = 'org/policy/label/logo/dark', MGMTLOGO = 'org/policy/label/logo', MGMTDARKICON = 'org/policy/label/icon/dark', MGMTICON = 'org/policy/label/icon', - IAMDARKLOGOPREVIEW = 'iam/policy/label/logo/dark/_preview', - IAMLOGOPREVIEW = 'iam/policy/label/logo/_preview', - IAMDARKICONPREVIEW = 'iam/policy/label/icon/dark/_preview', - IAMICONPREVIEW = 'iam/policy/label/icon/_preview', + IAMDARKLOGOPREVIEW = 'instance/policy/label/logo/dark/_preview', + IAMLOGOPREVIEW = 'instance/policy/label/logo/_preview', + IAMDARKICONPREVIEW = 'instance/policy/label/icon/dark/_preview', + IAMICONPREVIEW = 'instance/policy/label/icon/_preview', MGMTDARKLOGOPREVIEW = 'org/policy/label/logo/dark/_preview', MGMTLOGOPREVIEW = 'org/policy/label/logo/_preview', diff --git a/console/src/assets/i18n/de.json b/console/src/assets/i18n/de.json index 3aa3fc2c0..0db6d5edc 100644 --- a/console/src/assets/i18n/de.json +++ b/console/src/assets/i18n/de.json @@ -1479,7 +1479,9 @@ "SELECTEDREACTIVATED": "Selektierte Idps reaktiviert.", "SELECTEDDEACTIVATED": "Selektierte Idps deaktiviert.", "SELECTEDKEYSDELETED": "Selektierte Idps gelöscht.", - "DELETED": "Idp erfolgreich gelöscht!" + "DELETED": "Idp erfolgreich gelöscht!", + "ADDED": "Erfolgreich hinzugefügt.", + "REMOVED": "Erfolgreich entfernt." } }, "MFA": { diff --git a/console/src/assets/i18n/en.json b/console/src/assets/i18n/en.json index a349d4d47..6da1d2b19 100644 --- a/console/src/assets/i18n/en.json +++ b/console/src/assets/i18n/en.json @@ -1479,7 +1479,9 @@ "SELECTEDREACTIVATED": "Selected Idps reactivated.", "SELECTEDDEACTIVATED": "Selected Idps deactivated.", "SELECTEDKEYSDELETED": "Selected Idps deleted.", - "DELETED": "Idp removed successfully!" + "DELETED": "Idp removed successfully!", + "ADDED": "Added successfully.", + "REMOVED": "Removed successfully." } }, "MFA": { diff --git a/console/src/assets/i18n/it.json b/console/src/assets/i18n/it.json index f72208b2f..a73e0d37e 100644 --- a/console/src/assets/i18n/it.json +++ b/console/src/assets/i18n/it.json @@ -1479,7 +1479,9 @@ "SELECTEDREACTIVATED": "IDP selezionati riattivati.", "SELECTEDDEACTIVATED": "IDP selezionati disattivati.", "SELECTEDKEYSDELETED": "IDP selezionati cancellati.", - "DELETED": "IDP rimosso con successo!" + "DELETED": "IDP rimosso con successo!", + "ADDED": "Aggiunto con successo.", + "REMOVED": "Rimosso con successo." } }, "MFA": { diff --git a/internal/api/ui/login/static/resources/themes/scss/styles/checkbox/checkbox_theme.scss b/internal/api/ui/login/static/resources/themes/scss/styles/checkbox/checkbox_theme.scss index 5e241367a..fc8c9a5d4 100644 --- a/internal/api/ui/login/static/resources/themes/scss/styles/checkbox/checkbox_theme.scss +++ b/internal/api/ui/login/static/resources/themes/scss/styles/checkbox/checkbox_theme.scss @@ -38,7 +38,7 @@ } &:after { - border-color: #fff; // TODO replace with contrast to background color + border-color: var(--zitadel-color-primary-contrast); } } } diff --git a/internal/api/ui/login/static/resources/themes/zitadel/css/zitadel.css b/internal/api/ui/login/static/resources/themes/zitadel/css/zitadel.css index 1fa36841a..ebc5c7cee 100644 --- a/internal/api/ui/login/static/resources/themes/zitadel/css/zitadel.css +++ b/internal/api/ui/login/static/resources/themes/zitadel/css/zitadel.css @@ -2778,7 +2778,7 @@ input[type=checkbox]:checked + label:before { border-color: var(--zitadel-color-primary); } input[type=checkbox]:checked + label:after { - border-color: #fff; + border-color: var(--zitadel-color-primary-contrast); } .lgn-label {