0

I have read all posts regarding this issue but i cant' apply the solutions to my implementation. I have the following nodes in firebase: enter image description here

The service atached to a regular reactive form to register the user

export class UserService {

  constructor(private db: AngularFireDatabase) { }


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

And then the login:

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));
   }

And I get the message: There is no user record corresponding to this identifier. etc But as I read this is some kind of security feature from firebase. So what can I do work this around?

EDIT @Andrei

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));
   }

The error message remains the same, plus, i dont see any node created on the firebase console

1 Answer 1

1

AngularFireAuth stores users in some other internal collection, not users collection that you've created. you should create users with

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

not with filling your custom table

Sign up to request clarification or add additional context in comments.

2 Comments

ok, so this method i used I can use for other stuff, like posts?
your code suites for all models except for authentication

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.