Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //EXAMPLE 1
- public onSignup(): void {
- this.authService.signupUser(this.signupForm.value)
- .then(response => {
- let userObject = {
- uid: response.auth.uid,
- email: response.auth.email
- };
- setTimeout(() => this.authService.saveNewUserInDatabase(userObject) , 5000)})
- .then(() => {
- setTimeout(() => { this.router.navigate(['/map'])}, 1500);
- })
- .catch(error => {
- console.log(error);
- });
- }
- //EXAMPLE 2
- public onSignup(): void {
- this.authService.signupUser(this.signupForm.value)
- .then(response => {
- let userObject = {
- uid: response.auth.uid,
- email: response.auth.email
- };
- setTimeout(() => this.authService.saveNewUserInDatabase(userObject)
- .then(() => {
- setTimeout(() => { this.router.navigate(['/map'])}, 1500);
- }
- ), 5000)
- })
- .catch(error => {
- console.log(error)
- });
- }
- public signupUser(user: UserLogin): firebase.Promise<FirebaseAuthState> {
- return this.af.auth.createUser({email : user.email, password: user.password});
- }
- public saveNewUserInDatabase(user): firebase.database.ThenableReference {
- return firebase.database().ref().child("users").push(user);
- }
- .then()
- .then()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement