Confirm registration password Ionic 3

Asked

Viewed 440 times

0

I have a registration form on Ionic 3, but I can’t validate the password with another ion input.

Register.html:

<ion-item class = "log-input">
  <ion-label floating>Email</ion-label>
  <ion-input type="text" #username></ion-input>
</ion-item>

<ion-item class = "log-input">
  <ion-label floating>Senha</ion-label>
  <ion-input type="password" #password></ion-input>
</ion-item>

<ion-item class = "log-input">
  <ion-label floating>Confirmar</ion-label>
  <ion-input type="password" #conf></ion-input>
</ion-item>

Register

Register.ts

import { Component,ViewChild} from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController} from 'ionic-angular';
import { AngularFireAuth } from 'angularfire2/auth';


@IonicPage()
@Component({
  selector: 'page-register',
  templateUrl: 'register.html',
})
export class RegisterPage {
  @ViewChild('username') uname;
  @ViewChild('password') password;
  @ViewChild('password') conf;
  constructor(private alertCtrl:AlertController,private fire:AngularFireAuth, public navCtrl: NavController, public navParams: NavParams) {
  }

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

  alert(message:string){
    this.alertCtrl.create({
      title: 'Info',
      subTitle:message,
      buttons: ['OK']
    }).present();
  }

  registerUser(){
    this.fire.auth.createUserWithEmailAndPassword(this.uname.value, this.password.value, this.conf.value)
    .then(data=>{
     console.log("Sucesso",data);
     this.alert('Muito bem! Você está registrado.');
    })
    .catch(error =>{
      console.log('Erro',error);
      this.alert(error);
    })
    console.log("Registro com",this.uname.value , this.password.value);
  }
}

Well when I call 'this.conf.value'' in the user create method, it gives an error, ''Expected 2 Arguments, but got 3''.

1 answer

1


The function this.fire.auth.createUserWithEmailAndPassword admits only two arguments (email and password). You are trying to add a third party which, by its code, is also a password. You will not be able to use this method with the three information.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.