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 <[email protected]>
This commit is contained in:
Max Peintner
2022-05-31 13:51:21 +00:00
committed by GitHub
co-authored by Fabi
parent 16c86149be
commit e3e0207318
11 changed files with 121 additions and 108 deletions
@@ -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;
}
}
@@ -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);
}
}
});
}
@@ -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
@@ -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;