# Ionic phone authentication with firebase

**URL:** <https://forum.ionicframework.com/t/ionic-phone-authentication-with-firebase/129860>\
**Category:** ionic-v3\
**Created:** [May 7, 2018, 8:51am UTC](https://forum.ionicframework.com/t/ionic-phone-authentication-with-firebase/129860 "2018-05-07T08:51:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HackingCorp](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/hackingcorp/32/119216_2.png) [@HackingCorp](https://forum.ionicframework.com/u/HackingCorp)\
**Post date:** [May 7, 2018, 8:51am UTC](https://forum.ionicframework.com/t/ionic-phone-authentication-with-firebase/129860/1 "2018-05-07T08:51:24Z")

</div>

Hello dear ionic developer I have a little problem and I ask for your help. I develop an application and I add an authentication module with firebase phone number. But I would like to add a code at the level of app.compoment.ts so that the user only has to authenticate once. so each time he is redirected to the home page.

Thank you for your possible answer

---

<div class="post-metadata">

**Author:** ![robinyo](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/robinyo/32/115964_2.png) [@robinyo](https://forum.ionicframework.com/u/robinyo)\
**Post date:** [May 7, 2018, 11:46am UTC](https://forum.ionicframework.com/t/ionic-phone-authentication-with-firebase/129860/2 "2018-05-07T11:46:12Z")

</div>

Try:

```auto
@Component({
  templateUrl: 'app.component.html'
})
export class AppComponent {

  @ViewChild(Nav) private nav: Nav;

  public rootPage: any = 'SignInPage'; 

  constructor(public config: Config,
              public platform: Platform,
              private authService: AuthService,
              private swService: ServiceWorkerService,
              private logger: LoggerService) {

    this.initialiseApp();
  }

  private initialiseApp() {

    this.platform.ready().then(() => {
      this.logger.info('AppComponent: platform.ready()');
      this.swService.run();
    });

    this.authService.afAuth.authState.subscribe(user => {

        if (user) {
          this.rootPage = 'TabsPage';
        } else {
          this.rootPage = 'SignInPage';
        }
      }, () => {
        this.rootPage = 'SignInPage';
      }
    );

  }
}

```

See:

- [https://github.com/angular/angularfire2/blob/master/docs/auth/getting-started.md](https://github.com/angular/angularfire2/blob/master/docs/auth/getting-started.md)
- [https://firebase.google.com/docs/auth/web/manage-users](https://firebase.google.com/docs/auth/web/manage-users)

---

<div class="post-metadata">

**Author:** ![jaydz](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@jaydz](https://forum.ionicframework.com/u/jaydz)\
**Post date:** [May 7, 2018, 10:30pm UTC](https://forum.ionicframework.com/t/ionic-phone-authentication-with-firebase/129860/3 "2018-05-07T22:30:54Z")

</div>

@HackingCorp, Curious how you’re implementing phone auth in an ionic app. Are you using the reCaptcha verifier?

As far as i know, that won’t work in production…  
Am I mistaken?

---

<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:37pm UTC](https://forum.ionicframework.com/t/ionic-phone-authentication-with-firebase/129860/4 "2021-07-19T21:37:05Z")

</div>

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


