Property 'createUser' does not exist on type 'AngularFireAuth'


#1

Property 'createUser' does not exist on type 'AngularFireAuth'.
I am trying to implement authentication system using firebase but shows error when new user is creating account.
the code is

export class SignupComponent {
 state: string = '';
  error: any;
  constructor(public afAuth: AngularFireAuth,private router: Router) {  }
  onSubmit(formData) {
    if(formData.valid) {
      console.log(formData.value);
      this.afAuth.createUser({
        email: formData.value.email,
        password: formData.value.password
      }).then(
        (success) => {
        this.router.navigate(['/members'])
      }).catch(
        (err) => {
        this.error = err;
      })
    }
  }

#2

Where does this come from?


#3

The official Angular library for Firebase.
the updated angularfire 2


#4

Provide a link so we might look at the documentation.

Do you import AngularFireAuth in your component and app module? Did you add it to the app modules’ providers array? (Just a guess, could be different for Firebase)


#5

#6

My code for authorization is working fine. I’ll paste it here for you. My authentication function, ‘authUser()’, is written above the constructor, fyi. Another thing to check is if you are importing from ‘angularfire2/auth’

import { AngularFireAuth } from 'angularfire2/auth';
@component({
 selector: 'page-login',
  templateUrl: 'login-html',
})

export class LoginPage {
private register: FormGroup;

 authUser() {
  this.afAuth.createUserWithEmailAndPassword(this.register.value['email'], this.register.value['password'])
     .catch(function(error)  {
       let errorCode = error.name;
         let errorMessage = error.message;
             console.error('Error: ' + errorCode);
              console.error('Error Message: ' + errorMessage);
   })

}


constructor(public afAuth: AngularFireAuth, public formBuilder: FormBuilder)   {
 
this.register = this.formBuilder.group({
  email: ['', Validators.compose([Validators.maxLength(15), Validators.required])],
    password: ['', Validators.compose([Validators.maxLength(15), Validators.required])],
    })
  }

}

#7

So, on comparison, it looks like you could change this.afAuth.createUser to
this.afAuth.createUserWithEmailAndPassword
That might be the fix you need