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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 121 additions and 108 deletions

View File

@ -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;
}
}

View File

@ -41,7 +41,9 @@ export class FactorTableComponent {
@Input() service!: AdminService | ManagementService;
@Input() disabled: boolean = false;
@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;
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(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);
}
}
});
}

View File

@ -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

View File

@ -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<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 {
if (this.loginData && this.serviceType === PolicyComponentServiceType.MGMT) {
return (this.loginData as LoginPolicy.AsObject).isDefault;

View File

@ -89,7 +89,9 @@ export class ProjectGrantDetailComponent {
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 {
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',

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {

View File

@ -38,7 +38,7 @@
}
&: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);
}
input[type=checkbox]:checked + label:after {
border-color: #fff;
border-color: var(--zitadel-color-primary-contrast);
}
.lgn-label {