Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- //import { Http } from '@angular/http';
- import 'rxjs/add/operator/map';
- import firebase from 'firebase';
- @Injectable()
- export class ProfileData {
- public userProfile: any;
- public currentUser: any;
- constructor() {
- this.currentUser = firebase.auth().currentUser;
- this.userProfile = firebase.database().ref('/userProfile');
- }
- getUserProfile(): any {
- return this.userProfile.child(this.currentUser.uid);
- }
- updateName(firstName: string, lastName: string): any {
- return this.userProfile.child(this.currentUser.uid).update({
- firstName: firstName,
- lastName: lastName,
- });
- }
- updateDOB(birthDate: string): any {
- return this.userProfile.child(this.currentUser.uid).update({
- birthDate: birthDate,
- });
- }
- updateEmail(newEmail: string): any {
- this.currentUser.updateEmail(newEmail).then(() => {
- this.userProfile.child(this.currentUser.uid).update({
- email: newEmail
- });
- }, (error) => {
- console.log(error);
- });
- }
- updatePassword(newPassword: string): any {
- this.currentUser.updatePassword(newPassword).then(() => {
- console.log("Password Changed");
- }, (error) => {
- console.log(error);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement