fix: login checkbox contrast, login policy factors, asset urls (#3742)

* checkbox contrast

* idp create before remove, add, asset service

* login policy events

Co-authored-by: Fabi <38692350+hifabienne@users.noreply.github.com>
This commit is contained in:
Max Peintner
2022-05-31 15:51:21 +02:00
committed by GitHub
parent 16c86149be
commit e3e0207318
11 changed files with 121 additions and 108 deletions

View File

@@ -226,6 +226,7 @@ export class IdpTableComponent implements OnInit {
switch (this.serviceType) { switch (this.serviceType) {
case PolicyComponentServiceType.MGMT: case PolicyComponentServiceType.MGMT:
return (this.service as ManagementService).addIDPToLoginPolicy(idp.id, idp.owner).then(() => { return (this.service as ManagementService).addIDPToLoginPolicy(idp.id, idp.owner).then(() => {
this.toast.showInfo('IDP.TOAST.ADDED', true);
this.getIdps() this.getIdps()
.then((resp) => { .then((resp) => {
this.idps = resp; this.idps = resp;
@@ -238,6 +239,7 @@ export class IdpTableComponent implements OnInit {
return (this.service as AdminService) return (this.service as AdminService)
.addIDPToLoginPolicy(idp.id) .addIDPToLoginPolicy(idp.id)
.then(() => { .then(() => {
this.toast.showInfo('IDP.TOAST.ADDED', true);
this.getIdps().then((resp) => { this.getIdps().then((resp) => {
this.idps = resp; this.idps = resp;
}); });
@@ -251,28 +253,30 @@ export class IdpTableComponent implements OnInit {
public removeIdp(idp: IDP.AsObject): void { public removeIdp(idp: IDP.AsObject): void {
switch (this.serviceType) { switch (this.serviceType) {
case PolicyComponentServiceType.MGMT: 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.getIdps().then((resp) => {
this.idps = resp; this.idps = resp;
}); });
}, })
(error) => { .catch((error) => {
this.toast.showError(error); this.toast.showError(error);
}, });
);
break; break;
case PolicyComponentServiceType.ADMIN: 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.getIdps().then((resp) => {
this.idps = resp; this.idps = resp;
}); });
}, })
(error) => { .catch((error) => {
this.toast.showError(error); this.toast.showError(error);
}, });
);
break; break;
} }
} }

View File

@@ -41,7 +41,9 @@ export class FactorTableComponent {
@Input() service!: AdminService | ManagementService; @Input() service!: AdminService | ManagementService;
@Input() disabled: boolean = false; @Input() disabled: boolean = false;
@Input() list: Array<MultiFactorType | SecondFactorType> = []; @Input() list: Array<MultiFactorType | SecondFactorType> = [];
@Output() listChanged: EventEmitter<void> = new EventEmitter(); @Output() typeRemoved: EventEmitter<Promise<any>> = new EventEmitter();
@Output() typeAdded: EventEmitter<Promise<any>> = new EventEmitter();
@ViewChild(MatPaginator) public paginator!: MatPaginator; @ViewChild(MatPaginator) public paginator!: MatPaginator;
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false); private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
@@ -64,59 +66,33 @@ export class FactorTableComponent {
dialogRef.afterClosed().subscribe((resp) => { dialogRef.afterClosed().subscribe((resp) => {
if (resp) { if (resp) {
let request;
if (this.serviceType === PolicyComponentServiceType.MGMT) { if (this.serviceType === PolicyComponentServiceType.MGMT) {
if (this.componentType === LoginMethodComponentType.MultiFactor) { if (this.componentType === LoginMethodComponentType.MultiFactor) {
const req = new MgmtRemoveMultiFactorFromLoginPolicyRequest(); const req = new MgmtRemoveMultiFactorFromLoginPolicyRequest();
req.setType(type as MultiFactorType); req.setType(type as MultiFactorType);
(this.service as ManagementService) request = (this.service as ManagementService).removeMultiFactorFromLoginPolicy(req);
.removeMultiFactorFromLoginPolicy(req)
.then(() => {
this.toast.showInfo('MFA.TOAST.DELETED', true);
this.listChanged.emit();
})
.catch((error) => {
this.toast.showError(error);
});
} else if (this.componentType === LoginMethodComponentType.SecondFactor) { } else if (this.componentType === LoginMethodComponentType.SecondFactor) {
const req = new MgmtRemoveSecondFactorFromLoginPolicyRequest(); const req = new MgmtRemoveSecondFactorFromLoginPolicyRequest();
req.setType(type as SecondFactorType); req.setType(type as SecondFactorType);
(this.service as ManagementService) request = (this.service as ManagementService).removeSecondFactorFromLoginPolicy(req);
.removeSecondFactorFromLoginPolicy(req)
.then(() => {
this.toast.showInfo('MFA.TOAST.DELETED', true);
this.listChanged.emit();
})
.catch((error) => {
this.toast.showError(error);
});
} }
} else if (this.serviceType === PolicyComponentServiceType.ADMIN) { } else if (this.serviceType === PolicyComponentServiceType.ADMIN) {
if (this.componentType === LoginMethodComponentType.MultiFactor) { if (this.componentType === LoginMethodComponentType.MultiFactor) {
const req = new AdminRemoveMultiFactorFromLoginPolicyRequest(); const req = new AdminRemoveMultiFactorFromLoginPolicyRequest();
req.setType(type as MultiFactorType); req.setType(type as MultiFactorType);
(this.service as AdminService) request = (this.service as AdminService).removeMultiFactorFromLoginPolicy(req);
.removeMultiFactorFromLoginPolicy(req)
.then(() => {
this.toast.showInfo('MFA.TOAST.DELETED', true);
this.listChanged.emit();
})
.catch((error) => {
this.toast.showError(error);
});
} else if (this.componentType === LoginMethodComponentType.SecondFactor) { } else if (this.componentType === LoginMethodComponentType.SecondFactor) {
const req = new AdminRemoveSecondFactorFromLoginPolicyRequest(); const req = new AdminRemoveSecondFactorFromLoginPolicyRequest();
req.setType(type as SecondFactorType); req.setType(type as SecondFactorType);
(this.service as AdminService) request = (this.service as AdminService).removeSecondFactorFromLoginPolicy(req);
.removeSecondFactorFromLoginPolicy(req)
.then(() => {
this.toast.showInfo('MFA.TOAST.DELETED', true);
this.listChanged.emit();
})
.catch((error) => {
this.toast.showError(error);
});
} }
} }
if (request) {
this.typeRemoved.emit(request);
}
} }
}); });
} }
@@ -134,59 +110,33 @@ export class FactorTableComponent {
dialogRef.afterClosed().subscribe((mfaType: MultiFactorType | SecondFactorType) => { dialogRef.afterClosed().subscribe((mfaType: MultiFactorType | SecondFactorType) => {
if (mfaType) { if (mfaType) {
let request;
if (this.serviceType === PolicyComponentServiceType.MGMT) { if (this.serviceType === PolicyComponentServiceType.MGMT) {
if (this.componentType === LoginMethodComponentType.MultiFactor) { if (this.componentType === LoginMethodComponentType.MultiFactor) {
const req = new MgmtAddMultiFactorToLoginPolicyRequest(); const req = new MgmtAddMultiFactorToLoginPolicyRequest();
req.setType(mfaType as MultiFactorType); req.setType(mfaType as MultiFactorType);
(this.service as ManagementService) request = (this.service as ManagementService).addMultiFactorToLoginPolicy(req);
.addMultiFactorToLoginPolicy(req)
.then(() => {
this.toast.showInfo('MFA.TOAST.ADDED', true);
this.listChanged.emit();
})
.catch((error) => {
this.toast.showError(error);
});
} else if (this.componentType === LoginMethodComponentType.SecondFactor) { } else if (this.componentType === LoginMethodComponentType.SecondFactor) {
const req = new MgmtAddSecondFactorToLoginPolicyRequest(); const req = new MgmtAddSecondFactorToLoginPolicyRequest();
req.setType(mfaType as SecondFactorType); req.setType(mfaType as SecondFactorType);
(this.service as ManagementService) request = (this.service as ManagementService).addSecondFactorToLoginPolicy(req);
.addSecondFactorToLoginPolicy(req)
.then(() => {
this.toast.showInfo('MFA.TOAST.ADDED', true);
this.listChanged.emit();
})
.catch((error) => {
this.toast.showError(error);
});
} }
} else if (this.serviceType === PolicyComponentServiceType.ADMIN) { } else if (this.serviceType === PolicyComponentServiceType.ADMIN) {
if (this.componentType === LoginMethodComponentType.MultiFactor) { if (this.componentType === LoginMethodComponentType.MultiFactor) {
const req = new AdminAddMultiFactorToLoginPolicyRequest(); const req = new AdminAddMultiFactorToLoginPolicyRequest();
req.setType(mfaType as MultiFactorType); req.setType(mfaType as MultiFactorType);
(this.service as AdminService) request = (this.service as AdminService).addMultiFactorToLoginPolicy(req);
.addMultiFactorToLoginPolicy(req)
.then(() => {
this.toast.showInfo('MFA.TOAST.ADDED', true);
this.listChanged.emit();
})
.catch((error) => {
this.toast.showError(error);
});
} else if (this.componentType === LoginMethodComponentType.SecondFactor) { } else if (this.componentType === LoginMethodComponentType.SecondFactor) {
const req = new AdminAddSecondFactorToLoginPolicyRequest(); const req = new AdminAddSecondFactorToLoginPolicyRequest();
req.setType(mfaType as SecondFactorType); req.setType(mfaType as SecondFactorType);
(this.service as AdminService) request = (this.service as AdminService).addSecondFactorToLoginPolicy(req);
.addSecondFactorToLoginPolicy(req)
.then(() => {
this.toast.showInfo('MFA.TOAST.ADDED', true);
this.listChanged.emit();
})
.catch((error) => {
this.toast.showError(error);
});
} }
} }
if (request) {
this.typeAdded.emit(request);
}
} }
}); });
} }

View File

@@ -56,7 +56,8 @@
[serviceType]="serviceType" [serviceType]="serviceType"
[componentType]="LoginMethodComponentType.MultiFactor" [componentType]="LoginMethodComponentType.MultiFactor"
[list]="loginData.multiFactorsList" [list]="loginData.multiFactorsList"
(listChanged)="fetchData()" (typeRemoved)="removeFactor($event)"
(typeAdded)="addFactor($event)"
[disabled]=" [disabled]="
loginData?.passwordlessType === PasswordlessType.PASSWORDLESS_TYPE_NOT_ALLOWED || loginData?.passwordlessType === PasswordlessType.PASSWORDLESS_TYPE_NOT_ALLOWED ||
([ ([
@@ -106,7 +107,8 @@
[serviceType]="serviceType" [serviceType]="serviceType"
[componentType]="LoginMethodComponentType.SecondFactor" [componentType]="LoginMethodComponentType.SecondFactor"
[list]="loginData.secondFactorsList" [list]="loginData.secondFactorsList"
(listChanged)="fetchData()" (typeRemoved)="removeFactor($event)"
(typeAdded)="addFactor($event)"
[disabled]=" [disabled]="
([ ([
serviceType === PolicyComponentServiceType.ADMIN serviceType === PolicyComponentServiceType.ADMIN

View File

@@ -94,7 +94,9 @@ export class LoginPolicyComponent implements OnInit {
); );
} }
}) })
.catch(this.toast.showError); .catch((error) => {
this.toast.showError(error);
});
} }
public ngOnInit(): void { public ngOnInit(): void {
@@ -171,10 +173,7 @@ export class LoginPolicyComponent implements OnInit {
mgmtreq.setIgnoreUnknownUsernames(this.loginData.ignoreUnknownUsernames); mgmtreq.setIgnoreUnknownUsernames(this.loginData.ignoreUnknownUsernames);
mgmtreq.setDefaultRedirectUri(this.loginData.defaultRedirectUri); mgmtreq.setDefaultRedirectUri(this.loginData.defaultRedirectUri);
// if(this.loginData.passwordCheckLifetime) { if (this.isDefault) {
// mgmtreq.setPasswordCheckLifetime(this.loginData.passwordCheckLifetime);
// }
if ((this.loginData as LoginPolicy.AsObject).isDefault) {
return (this.service as ManagementService).addCustomLoginPolicy(mgmtreq); return (this.service as ManagementService).addCustomLoginPolicy(mgmtreq);
} else { } else {
return (this.service as ManagementService).updateCustomLoginPolicy(mgmtreq); return (this.service as ManagementService).updateCustomLoginPolicy(mgmtreq);
@@ -204,7 +203,6 @@ export class LoginPolicyComponent implements OnInit {
adminreq.setMultiFactorCheckLifetime(admin_mficl); adminreq.setMultiFactorCheckLifetime(admin_mficl);
adminreq.setIgnoreUnknownUsernames(this.loginData.ignoreUnknownUsernames); adminreq.setIgnoreUnknownUsernames(this.loginData.ignoreUnknownUsernames);
adminreq.setDefaultRedirectUri(this.loginData.defaultRedirectUri); adminreq.setDefaultRedirectUri(this.loginData.defaultRedirectUri);
// adminreq.setPasswordCheckLifetime(this.loginData.passwordCheckLifetime);
return (this.service as AdminService).updateLoginPolicy(adminreq); return (this.service as AdminService).updateLoginPolicy(adminreq);
} }
@@ -256,6 +254,57 @@ export class LoginPolicyComponent implements OnInit {
} }
} }
public removeFactor(request: Promise<unknown>): 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<unknown>): void {
// create policy before types can be added
const task: Promise<unknown> = 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 { public get isDefault(): boolean {
if (this.loginData && this.serviceType === PolicyComponentServiceType.MGMT) { if (this.loginData && this.serviceType === PolicyComponentServiceType.MGMT) {
return (this.loginData as LoginPolicy.AsObject).isDefault; return (this.loginData as LoginPolicy.AsObject).isDefault;

View File

@@ -89,7 +89,9 @@ export class ProjectGrantDetailComponent {
this.breadcrumbService.setBreadcrumb(breadcrumbs); this.breadcrumbService.setBreadcrumb(breadcrumbs);
} }
}) })
.catch(this.toast.showError); .catch((error) => {
this.toast.showError(error);
});
}); });
} }

View File

@@ -18,23 +18,23 @@ export enum AssetType {
} }
export enum AssetEndpoint { export enum AssetEndpoint {
IAMFONT = 'iam/policy/label/font', IAMFONT = 'instance/policy/label/font',
MGMTFONT = 'org/policy/label/font', MGMTFONT = 'org/policy/label/font',
IAMDARKLOGO = 'iam/policy/label/logo/dark', IAMDARKLOGO = 'instance/policy/label/logo/dark',
IAMLOGO = 'iam/policy/label/logo', IAMLOGO = 'instance/policy/label/logo',
IAMDARKICON = 'iam/policy/label/icon/dark', IAMDARKICON = 'instance/policy/label/icon/dark',
IAMICON = 'iam/policy/label/icon', IAMICON = 'instance/policy/label/icon',
MGMTDARKLOGO = 'org/policy/label/logo/dark', MGMTDARKLOGO = 'org/policy/label/logo/dark',
MGMTLOGO = 'org/policy/label/logo', MGMTLOGO = 'org/policy/label/logo',
MGMTDARKICON = 'org/policy/label/icon/dark', MGMTDARKICON = 'org/policy/label/icon/dark',
MGMTICON = 'org/policy/label/icon', MGMTICON = 'org/policy/label/icon',
IAMDARKLOGOPREVIEW = 'iam/policy/label/logo/dark/_preview', IAMDARKLOGOPREVIEW = 'instance/policy/label/logo/dark/_preview',
IAMLOGOPREVIEW = 'iam/policy/label/logo/_preview', IAMLOGOPREVIEW = 'instance/policy/label/logo/_preview',
IAMDARKICONPREVIEW = 'iam/policy/label/icon/dark/_preview', IAMDARKICONPREVIEW = 'instance/policy/label/icon/dark/_preview',
IAMICONPREVIEW = 'iam/policy/label/icon/_preview', IAMICONPREVIEW = 'instance/policy/label/icon/_preview',
MGMTDARKLOGOPREVIEW = 'org/policy/label/logo/dark/_preview', MGMTDARKLOGOPREVIEW = 'org/policy/label/logo/dark/_preview',
MGMTLOGOPREVIEW = 'org/policy/label/logo/_preview', MGMTLOGOPREVIEW = 'org/policy/label/logo/_preview',

View File

@@ -1479,7 +1479,9 @@
"SELECTEDREACTIVATED": "Selektierte Idps reaktiviert.", "SELECTEDREACTIVATED": "Selektierte Idps reaktiviert.",
"SELECTEDDEACTIVATED": "Selektierte Idps deaktiviert.", "SELECTEDDEACTIVATED": "Selektierte Idps deaktiviert.",
"SELECTEDKEYSDELETED": "Selektierte Idps gelöscht.", "SELECTEDKEYSDELETED": "Selektierte Idps gelöscht.",
"DELETED": "Idp erfolgreich gelöscht!" "DELETED": "Idp erfolgreich gelöscht!",
"ADDED": "Erfolgreich hinzugefügt.",
"REMOVED": "Erfolgreich entfernt."
} }
}, },
"MFA": { "MFA": {

View File

@@ -1479,7 +1479,9 @@
"SELECTEDREACTIVATED": "Selected Idps reactivated.", "SELECTEDREACTIVATED": "Selected Idps reactivated.",
"SELECTEDDEACTIVATED": "Selected Idps deactivated.", "SELECTEDDEACTIVATED": "Selected Idps deactivated.",
"SELECTEDKEYSDELETED": "Selected Idps deleted.", "SELECTEDKEYSDELETED": "Selected Idps deleted.",
"DELETED": "Idp removed successfully!" "DELETED": "Idp removed successfully!",
"ADDED": "Added successfully.",
"REMOVED": "Removed successfully."
} }
}, },
"MFA": { "MFA": {

View File

@@ -1479,7 +1479,9 @@
"SELECTEDREACTIVATED": "IDP selezionati riattivati.", "SELECTEDREACTIVATED": "IDP selezionati riattivati.",
"SELECTEDDEACTIVATED": "IDP selezionati disattivati.", "SELECTEDDEACTIVATED": "IDP selezionati disattivati.",
"SELECTEDKEYSDELETED": "IDP selezionati cancellati.", "SELECTEDKEYSDELETED": "IDP selezionati cancellati.",
"DELETED": "IDP rimosso con successo!" "DELETED": "IDP rimosso con successo!",
"ADDED": "Aggiunto con successo.",
"REMOVED": "Rimosso con successo."
} }
}, },
"MFA": { "MFA": {

View File

@@ -38,7 +38,7 @@
} }
&:after { &:after {
border-color: #fff; // TODO replace with contrast to background color border-color: var(--zitadel-color-primary-contrast);
} }
} }
} }

View File

@@ -2778,7 +2778,7 @@ input[type=checkbox]:checked + label:before {
border-color: var(--zitadel-color-primary); border-color: var(--zitadel-color-primary);
} }
input[type=checkbox]:checked + label:after { input[type=checkbox]:checked + label:after {
border-color: #fff; border-color: var(--zitadel-color-primary-contrast);
} }
.lgn-label { .lgn-label {