我有一个 Ionic 应用程序需要在 Azure 中进行身份验证,因此我按照本教程安装了 MSAL: https: //learn.microsoft.com/en-us/graph/tutorials/angular
它的工作原理就像“离子服务”的魅力,但当我在设备中运行它时,当我尝试登录 Azure 时它会崩溃。我认为这是因为 MSAL 显示的弹出窗口在 Ionic 中不允许登录。
所以我的第一次尝试是将loginPopup() 调用更改为loginRedirect()。所以我删除了这段代码:
async signIn(): Promise<void> {
const result = await this.msalService
.loginPopup(OAuthSettings)
.toPromise()
.catch((reason) => {
this.alertsService.addError('Login failed',
JSON.stringify(reason, null, 2));
});
if (result) {
this.msalService.instance.setActiveAccount(result.account);
this.authenticated = true;
this.user = await this.getUser();
}
}
Run Code Online (Sandbox Code Playgroud)
我添加了这个新的(基于https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/errors.md):
async signIn(): Promise<void> {
await this.msalService.instance.handleRedirectPromise();
const accounts = this.msalService.instance.getAllAccounts();
if (accounts.length === 0) {
// No user signed in
this.msalService.instance.loginRedirect();
}
}
Run Code Online (Sandbox Code Playgroud)
但这样,用户信息不会保存,因为我没有“结果”来处理或调用 setActiveAccount(result)。即使在“离子服务”中它也不起作用,所以我放弃了这种方法。
azure-active-directory ionic-framework azure-ad-msal ionic-native msal-angular
我有这些拖车桌:
CREATE TABLE cities (
city varchar(80) primary key,
location point
);
CREATE TABLE weather (
city varchar(80) references cities(city),
temp_lo int,
temp_hi int,
prcp real,
date date
);
Run Code Online (Sandbox Code Playgroud)
我正在使用 PostgreSQL 和 Knex JavaScript 驱动程序
在执行插入事务时,如何确保如果在插入表城市后插入表天气时出现错误,我可以返回并删除表城市中的插入以确保数据库完整性。拜托,我只需要看看我能做什么。