Pls help me i am new in angular6 firebase programing. I have good working firebase auth system with email and password. But from registration i can only get uid and email when i store User in database. I red about updateProfile but dont know how to implement in my code. I am using "@angular/fire": "^5.0.0", "firebase": "^5.5.1", so i am asking is this version good or i need to change. Back to question: Service:
import { Injectable } from "@angular/core";
import { AngularFireAuth } from "@angular/fire/auth";
import {
AngularFirestore,
AngularFirestoreCollection,
AngularFirestoreDocument
} from "@angular/fire/firestore";
import { Observable } from "rxjs";
import "rxjs/add/operator/map";
@Injectable()
export class AuthService {
constructor(private afAuth: AngularFireAuth, private db: AngularFirestore) {
// this.afAuth.authState.subscribe(auth => console.log(auth));
}
login(email: string, password: string) {
return new Promise((resolove, reject) => {
this.afAuth.auth
.signInWithEmailAndPassword(email, password)
.then(userData => resolove(userData), err => reject(err));
});
}
getAuth() {
return this.afAuth.authState.map(auth => auth);
}
logout() {
this.afAuth.auth.signOut();
}
register(email: string, password: string) {
return new Promise((resolove, reject) => {
this.afAuth.auth
.createUserWithEmailAndPassword(email, password)
.then(userData => resolove(userData), err => reject(err));
});
}
}
Component
import { Component, OnInit } from "@angular/core";
import { AuthService } from "../../service/auth.service";
import { Router } from "@angular/router";
@Component({
selector: "app-register",
templateUrl: "./register.component.html",
styleUrls: ["./register.component.css"]
})
export class RegisterComponent implements OnInit {
email: string;
password: string;
constructor(private authService: AuthService, private router: Router) {}
ngOnInit() {}
onSubmit() {
this.authService
.register(this.email, this.password)
.then(res => {
this.router.navigate(["/"]);
})
.catch(err => console.log(err.message));
}
}
My goal is to have displayName and skill as property of User in database. After registration with my code displayName is null. So my question is how to store displayName in database? Ty Viktor.