Abhishek Singh
Abhishek Singh

Reputation: 563

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.

Property ‘createUser’ does not exist on type ‘AngularFireAuth’

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

Upvotes: 1

Views: 2198

Answers (1)

Derrick Miller
Derrick Miller

Reputation: 1951

According to the Angularfire2 docs, "AngularFireAuth.auth returns an initialized firebase.auth.Auth instance, allowing you to log users in, out, etc." They offer a code example which includes this line:

this.afAuth.auth.signInWithPopup(new auth.GoogleAuthProvider());

The Angularfire docs go on to say "see the Firebase docs for more information on what methods are available." Looking at those docs, it appears there is no longer a createUser method. There is, however, one called createUserWithEmailAndPassword().

So, try using this.afAuth.auth.createUserWithEmailAndPassword().

Upvotes: 2

Related Questions