Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentWillLoad() {
authState(firebase.auth()).subscribe(u => (this.user = u));
// Get associated user todos
authState(firebase.auth())
.pipe(
switchMap(user => {
// Define the query
if (user) {
const query = this.ref.where('user', '==', user.uid);
return collectionData(query, 'taskId');
} else {
return [];
}
})
)
.subscribe(docs => (this.todos = docs));
}
componentWillLoad() {
authState(firebase.auth()).subscribe(u => (this.user = u));
// Get associated user todos
authState(firebase.auth())
.pipe(
switchMap(user => {
// Define the query
if (user) {
const query = this.ref.where('user', '==', user.uid);
return collectionData(query, 'taskId');
} else {
return [];
}
})
)
.subscribe(docs => (this.todos = docs));
}
export const authListener = firebaseApp => {
authState(firebaseApp.auth()).subscribe(async user => {
if (user) {
const token = await user.getIdToken(true)
const idTokenResult = await user.getIdTokenResult()
const hasuraClaim = idTokenResult.claims['https://hasura.io/jwt/claims']
authStore.set({ status: 'in', user, token })
if (hasuraClaim) {
authStore.set({ status: 'in', user, token })
localStorage.setItem('token', token)
}
}
})
}