更新
我将此插件用于电话验证https://ionicframework.com/docs/native/firebase-authentication。那么如何将Auth详细信息传输到AngulraFireAuth?
async signIn(): Promise<void> {
await this.firebaseAuthentication.signInWithVerificationId(verificationId, securityCode);
}
auth.service.ts
onAuthStateChanged(): void {
this.firebaseAuthentication.onAuthStateChanged().subscribe((res) => {
this.zone.run(async () => {
if (res) {
// code
});
});
}
原始
我具有Firebase存储桶权限,如下所示:Firestore
也是如此。
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write:if request.auth != null;
}
}
}
客户端代码:即上传图片
console.log('user', await this.afAuth.currentUser); //null
const filePath: string = `signatures/${user.uid}`;
const afUploadTask: AngularFireUploadTask = afStorageReference.putString(imageDataUrl, 'data_url');
但是失败了:
vendor.js:44100错误错误:未捕获(已承诺): FirebaseStorageError: {“ code_”:“存储/未授权”,“ message _”:“ Firebase存储:用户 没有访问权限 'signatures / gx3TlaSFQoPhQXCnjk3QCrq2j9x1'。“,” serverResponse _“:” {\ n “错误”:{\ n“代码”:403,\ n“消息”:“权限 否认。无法执行此操作“ \ n } \ n}“,” name _“:” FirebaseError“}
那么我该如何使用Storage配置这种规则?上面的代码没有任何规则就可以正常工作。