Hello Im doing an app in angular, firebase and ionic. I have used a login starter in my app and I want my app to register with a username, email and password. I need the username for later in the app to put Hello [username]. I have the option to register firebase with the property .createUserWithEmailAndPassword(email, password)this property only allows the registration of email and password, how can I add a parameter for username? I would appreciate detailed explanation I am a noob.
I have the code divided into a page and a service and the html part. -HTML PAGE
<ion-item lines="none">
<ion-input class="placeholdertext inputField" type="text" placeholder="Username" [(ngModel)]="name" autofocus="true" padding-start></ion-input>
</ion-item>
<ion-item lines="none">
<ion-input class="placeholdertext inputField" type="text" placeholder="nombre@dominio.com" [(ngModel)]="email" autofocus="true" padding-start></ion-input>
</ion-item>
<ion-item lines="none">
<ion-input class="placeholdertext inputField" type="password" placeholder="Contraseña" [(ngModel)]="password" padding-start clearInput></ion-input>
</ion-item>
-REGISTER PAGE TS
register() {
this.spinner = true;
this.disabled = true;
this.auth
.signupUser(this.email, this.password)
.then(res => {
console.log(res);
this.auth.writeNewUser(this.email, res.user.uid)
.then(response => {
this.auth.getUser(res.user.uid).then(user => {
this.spinner = false;
this.disabled = false;
this.route.navigate(['approved']);
console.log(this.email, this.password );
});
})
})
-FINALLY THE AUTH SERVICE
signupUser(email: string, password: string): Promise<any> {
return this.afAuth.auth
.createUserWithEmailAndPassword(email, password)//In this part it does not let me add another parameter
}
writeNewUser( email: string, uid: string): Promise<any> {
console.log(name, uid, email)
return this.db
.collection('drivers')
.doc(uid)
.set({
email: email,
available: false,
approved: false
});
}
loginUser( email: string, password: string): Promise<any> {
return this.afAuth.auth.signInAndRetrieveDataWithEmailAndPassword( email, password);
}
signupUser(email: string, password: string): Promise<any> {
return this.afAuth.auth
.createUserWithEmailAndPassword(email, password)
}
As I said before I want both in the registration and login can add another password to enter a username, then when the user login start the app with your username and put hello [username]. Adjoint where this property comes out. createuserwithemailandpassword. https://firebase.google.com/docs/auth/web/manage-users?hl=en-419
I appreciate any help. I also speak Spanish