Firebase / Angular: auth-user-not found - PullRequest
       0

Firebase / Angular: auth-user-not found

0 голосов
/ 16 февраля 2020

Я прочитал все сообщения по этой проблеме, но я не могу применить решения к моей реализации. У меня есть следующие узлы в firebase: enter image description here

Служба привязана к обычной реактивной форме для регистрации пользователя

export class UserService {

  constructor(private db: AngularFireDatabase) { }


createUser(user:User){
   this.db.list('/users').push(user)
}

И затем логин:

constructor(private afAuth: AngularFireAuth,
    private db: AngularFireDatabase,
    private router: Router) { }


  emailLogin(email:string, password:string) {

    return this.afAuth.auth.signInWithEmailAndPassword(email, password)
    .then((user) => {
       console.log("user details:",user);
       this.router.navigate(['/home']);
       console.log('Successfully Signed In');
     }).catch((error) => console.log(error));
   }

И я получаю сообщение: There is no user record corresponding to this identifier. etc Но когда я читаю, это какая-то функция безопасности от firebase. Так что я могу сделать, чтобы обойти это?

РЕДАКТИРОВАТЬ @ Андрей

AuthService:

  createUser(email:string, password:string){
    this.afAuth.auth.createUserWithEmailAndPassword(email, password)
    .then((user)=>{
      this.router.navigate(['/login']);
      console.log('Successfully registered');

    }).catch(error=>console.log(error))
  }

  emailLogin(email:string, password:string) {

    return this.afAuth.auth.signInWithEmailAndPassword(email, password)
    .then((user) => {
      localStorage.setItem('currentUser', JSON.stringify(user));
       console.log("user details:",user);
       this.router.navigate(['/home']);
       console.log('Successfully Signed In');
     }).catch((error) => console.log(error));
   }

Сообщение об ошибке остается тем же, плюс, я не вижу ни одного созданного узла на пожарной консоли

1 Ответ

1 голос
/ 16 февраля 2020

AngularFireAuth хранит пользователей в какой-то другой внутренней коллекции, а не в пользовательской коллекции, которую вы создали. вы должны создавать пользователей с

 this.afAuth.auth.createUserWithEmailAndPassword(email, passwors)

, а не с заполнением вашей пользовательской таблицы

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...