I'm trying to create a function where I grab the info of my collection to login into my application
I can already get all the information using this service:
getUsersLocal(): Observable<AdminUser[]> {
const booksRef = collection(this.firestore, 'admin-roles');
return collectionData(booksRef, { idField: 'id' }) as Observable<AdminUser[]>;
}
now to the function part:
login(): void{
if(this.loginForm?.valid){
let adminLogin: Admin = this.loginForm.value;
this.admin.getUsersLocal().subscribe({
next: response => {
if(this.email === adminEmail && this.password === adminPassword){
this.route.navigate(['/admin']);
}
} else {
window.alert("Usuário não encontrado")
}
})
}
}
I know that it is wrong the construction, but I think it's somewhat around that.