Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

The user authentication by firestore

I use firestore to user's sign up, the user should add his or her name, email , password, and picture. I want a check if the user sign up or log in to make his or her name appear in the side menu

how can I do that by using firestore , i know we can use firestore.auth().curretunuser or something like this

anyone can help me, please or there is any idea to do that

this app.ts

```

 export class MyApp {
    @ViewChild(Nav) nav: Nav;

  rootPage: any = HomePage;

   pages: Array<{title: string, component: any}>;
   username;
       constructor(public platform: Platform, 

   public statusBar: StatusBar, public splashScreen: SplashScreen) {
     this.initializeApp();

// used for an example of ngFor and navigation

  this.pages = [
    { title: 'home', component: HomePage },
     { title: 'list', component: ListPage },
     { title: 'login', component: LoginComponent },
     { title: 'my', component: MypagePage }

     ];

     }

        initializeApp() {
       this.platform.ready().then(() => {

      this.statusBar.styleDefault();
      this.splashScreen.hide();
    });
  }

  openPage(page) {

    this.nav.setRoot(page.component);
  }

 }

```

this app.html ```

 <ion-menu [content]="content" side="right">
  <ion-header>
   <ion-toolbar>
  <ion-title text-right>menu</ion-title>
</ion-toolbar>
 </ion-header>

<ion-content>

  <div class="profile" slide-element="2">
     <!--  <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet"> -->

      <i class="ion-android-person"></i> 
    </div>


<ion-list >
    <button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)" 
text-right>
       {{p.title}}
     </button>
   </ion-list>
   </ion-content>

```

this sign up .html

```

    <ion-header >
   <ion-navbar>
  <button ion-button menuToggle right>
    <ion-icon name="menu"></ion-icon>
   </button>
  <ion-title text-right>signup</ion-title>
 </ion-navbar>
</ion-header>


  <ion-content padding >

   <form (ngSubmit)="register()" #registerForm="ngForm">
    <ion-row>
      <ion-col>
       <ion-list inset>

         <ion-item>
            <ion-input text-right type="text" placeholder="name" name="name" 
  [(ngModel)]="usersadd.name" #name required></ion-input>
          </ion-item>

         <ion-item>
           <ion-input type="text" text-right placeholder="email" 
   name="email" [(ngModel)]="usersadd.email" required></ion-input>
         </ion-item>

          <ion-item>
           <ion-input text-right type="password"  placeholder="passwod" 
 name="password" [(ngModel)]="usersadd.password" required></ion-input>
          </ion-item>


       </ion-list>
     </ion-col>
       </ion-row>

         <ion-row>
          <ion-col class="signup-col">
        <button ion-button class="submit-btn" full type="submit" 
 [disabled]="!registerForm.form.valid" (click)= "moveto(name.value)"  
 >signup</button>
      </ion-col>
    </ion-row>

    </form>

    </ion-content>

```

signup.ts ```

  export class SignupPage {
 registerForm :FormGroup;
  usersadd: users={
    email:'' ,
    password:'' ,
   name:'' ,
   }

   constructor(public navCtrl: NavController, public navParams: NavParams, 
 public loadcontoll : LoadingController
     ,public fb : FormBuilder, public 
    firestoreService:FierbaceserverProvider, public atetcontol 
    :AlertController
        , public toastcontoll :ToastController) {

        }

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

  moveto(name){
 name=name;
this.navCtrl.setRoot(HomePage, {data: name});
    }

   register(){
  const load =this.loadcontoll.create({
   content:'wait......'

  })
 load.present();
    if(this.usersadd.email!== '' && this.usersadd.password!== '' && 
   this.usersadd.name!== ''  ){
      this.firestoreService.signupuser(this.usersadd);
     this.usersadd.name='';
      this.usersadd.email='';
      this.usersadd.password='';
        load.dismiss();
     const toast =this.toastcontoll.create({
       message:'success',
    duration: 3000,
        })
 toast.present();
    }

else()=>{
  load.dismiss();
  const alet =this.atetcontol.create({
    title:'wrong ',
    message:'wrong ',
    //message: error.message,

    buttons:['ok']
     })
alet.present();
    }

  }
}

```

Comments