这个想法是当用户处理某些东西并尝试运行一些敏感组件时,他需要确认密码。这样,我们可以验证用户身份。 确认密码对话框如下所示:
appGlobal.service.ts中的方法
OpenACLModal() {
this.aclModal.open(AccessControlListComponent, { width: '450px' });
}
这是access-control-list.service.ts中的Open方法
//Open a new dialog window with the specified configuration.
open(content: any, config: MatDialogConfig = {}): MatDialogRef<any> {
const dialog = this.dialog.open(content, config);
this.stack.push(dialog);
return dialog;
}
因此,现在我可以只用appGlobal.service.ts
中引用的一行代码触发模态 let modal = this.appGlobal.OpenACLModal();
当我在模式上单击“确定”时,将执行以下操作:
AuthUser() {
let auth = new Authorize();
auth.Credentials.CredentialsData1 = this.email;
auth.Credentials.CredentialsData2 = this.password;
this.http.post(this.appGlobal.BASE_SERVER_ADDRESS + 'api/AppServer/Authorize', auth).subscribe((res) => {
if (res['IsAuthorized'] == true) {
// do something
}
else // do something
});
}
问:我想做类似的事情:
let modal = this.appGlobal.OpenACLModal();
if (modal==true)
{
// I want to freeze code here and wait for the response of modal
// Check response if true
// do something
}
else alert("You don't have permission to perform this kind of action");
该怎么做?谢谢任何人。