# Cannot read property 'auth' of undefined

**URL:** <https://forum.ionicframework.com/t/cannot-read-property-auth-of-undefined/147355>\
**Category:** ionic-v3\
**Created:** [November 12, 2018, 9:04pm UTC](https://forum.ionicframework.com/t/cannot-read-property-auth-of-undefined/147355 "2018-11-12T21:04:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jagr2713](https://avatars.discourse-cdn.com/v4/letter/j/b4bc9f/32.png) [@jagr2713](https://forum.ionicframework.com/u/jagr2713)\
**Post date:** [November 12, 2018, 9:04pm UTC](https://forum.ionicframework.com/t/cannot-read-property-auth-of-undefined/147355/1 "2018-11-12T21:04:09Z")

</div>

```auto
    ERROR TypeError: Cannot read property 'auth' of undefined
    at LoginPage.webpackJsonp.149.LoginPage.login (login.ts:31)
    at Object.eval [as handleEvent] (LoginPage.html:31)
    at handleEvent (core.js:13589)
    at callWithDebugContext (core.js:15098)
    at Object.debugHandleEvent [as handleEvent] (core.js:14685)
    at dispatchEvent (core.js:10004)
    at core.js:10629
    at HTMLButtonElement.<anonymous> (platform-browser.js:2628)
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (core.js:4751)

```

```auto
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

import { AngularFireAuth } from '@angular/fire/auth';

/**
 * Generated class for the LoginPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-login',
  templateUrl: 'login.html',
})
export class LoginPage {

  email: string;
  password : string; 
  private aAuth : AngularFireAuth;
  constructor(aAuth : AngularFireAuth, public navCtrl: NavController, public navParams: NavParams) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad LoginPage');
  }

  login(){
   this.aAuth.auth.signInWithEmailAndPassword(this.email, this.password).then(e => {console.log(e)})
  }

}

```

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [November 12, 2018, 9:38pm UTC](https://forum.ionicframework.com/t/cannot-read-property-auth-of-undefined/147355/2 "2018-11-12T21:38:50Z")

</div>

The error message tells you exactly what is happening. You have never assigned anything to the `aAuth` property. The most idiomatic solution is to remove the explicit property declaration and simply add the `private` access qualifier to the constructor parameter, which will cause TypeScript to automatically define and initialize the property.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:09pm UTC](https://forum.ionicframework.com/t/cannot-read-property-auth-of-undefined/147355/3 "2021-07-19T21:09:43Z")

</div>

Closed on July 19, 2021, 9:09pm UTC


