我正在尝试使用以下代码在 AngularFire 中实现持久性身份验证:
constructor(private auth: Auth, private router: Router) {
if (auth.currentUser) this.router.navigate(this.redirect);
}
async loginWithGoogle() {
const provider = new GoogleAuthProvider();
try {
await setPersistence(this.auth, browserLocalPersistence);
await signInWithPopup(this.auth, provider);
this.message = 'Sign in successful';
await this.router.navigate(this.redirect);
} catch (error: any) {
console.error(error);
if (error.code) {
this.message = `${error.code}: ${error.message}`;
} else {
this.message = 'There was a problem signing in. Please try again.';
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,无论方法的位置如何,我总是收到此错误setPersistence:
Class constructor BrowserLocalPersistence cannot be invoked without 'new'
Run Code Online (Sandbox Code Playgroud)
我按照文档(https://firebase.google.com/docs/auth/web/auth-state-persistence …
firebase firebase-authentication angularfire2 angular rxfire
尝试使用 RxFire 在 Google Cloud Storage 中上传大型图像文件时,出现错误:存储/未找到对象。
\n\n他们说在桶中找不到该图像,但当我检查时,我看到了它们!
\n\n我用小图像(可能是 100kb...)进行了测试,效果很好。
\n\n但尝试使用 > 500kb 图像,不起作用......
\n\nupload$\n .pipe(\n switchMap((event: any) => {\n const name = Math.random().toString(36).substring(5);\n const blob = event.target.files[0];\n const type = blob.type.replace(\'image/\', \'\');\n const ref = storage.ref(`uploads/test/${name}.${type}`);\n return put(ref, blob);\n }),\n map(snapshot => snapshot),\n filter(snapshot => snapshot.totalBytes === snapshot.bytesTransferred),\n mergeMap(snapshot => getDownloadURL(snapshot.ref))\n )\n .subscribe(url => {\n console.log(\'Results\', url)\n }, (error) => {\n // ERROR HERE\n console.log(\'error\', error)\n })\nRun Code Online (Sandbox Code Playgroud)\n\n预期结果:上传处理大图像
\n\n实际结果:错误
\n\nUncaught t\xc2\xa0{code_: "storage/object-not-found", …Run Code Online (Sandbox Code Playgroud) 我们的目标很简单:将两个公司的FireStore查询利用rxjs,rxfire以及rnfirebase反应机库.
//Simple test for collectionData
import { collectionData } from 'rxfire/firestore';
this.myQuery = this.props.docRef.collection(`messages`).where('read', 'array-contains', this.props.me.uid)
collectionData(this.myQuery, 'id').subscribe(docs => console.log(docs))
//Fails with error: this._next is not a function.
Run Code Online (Sandbox Code Playgroud)
或者,
this.publicQuery = this.props.docRef.collection('messages').where('public', '==', true)
this.myQuery = this.props.docRef.collection(`messages`).where('read', 'array-contains', this.props.me.uid)
const myQuery$ = new Rx.Subject();
const publicQuery$ = new Rx.Subject();
this.myQuery.onSnapshot((querySnapshot) => {
myQuery$.next(querySnapshot.docs.map(d => d.data() ));
});
this.publicQuery.onSnapshot((querySnapshot) => {
publicQuery$.next(querySnapshot.docs.map(d => d.data() ));
});
const orQuery$ = combineLatest(this.myQuery, …Run Code Online (Sandbox Code Playgroud)