【发布时间】:2019-07-22 10:53:09
【问题描述】:
我正在尝试为我正在处理的应用程序创建管理 CRM。为此,我有一个连接到主应用程序的云功能,它为 CRM 应用程序上的用户创建自定义令牌。我创建该令牌的方式如下:
return admin.auth().createCustomToken(uid, {admin: true}).then((token: string) => {
console.log('Custom ID created!');
return res.status(200).send(token);
})
然后我以用户身份登录 CRM,将 uid 传递回此函数。在创建令牌时,我将其传递给 firestore 函数signInWithCustomToken(token)。主要提到的登录功能如下:
signInWithEmailAndPassword(user): Observable<any> {
return from(this.afAuth.auth.signInWithEmailAndPassword(user.email, user.password))
.pipe(
flatMap((res: any) => this.createAdminCustomtoken(res.user.uid)),
flatMap((token: any) => this.signInWithToken(token))
);
}
但是,当我发送此请求时,我收到以下错误:
据我了解,此错误是因为我试图在另一个项目中提供一个项目的令牌 - 但是,这种行为是我需要做的事情。有解决方法吗?或者有没有更好的方法。
【问题讨论】:
标签: javascript node.js firebase-authentication firebase-admin