Advertisement
Guest User

Untitled

a guest
Feb 14th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Injectable } from '@angular/core';
  2. //import { Http } from '@angular/http';
  3. import 'rxjs/add/operator/map';
  4. import firebase from 'firebase';
  5.  
  6. @Injectable()
  7. export class ProfileData {
  8.   public userProfile: any;
  9.   public currentUser: any;
  10.  
  11.  
  12.   constructor() {
  13.     this.currentUser = firebase.auth().currentUser;
  14.     this.userProfile = firebase.database().ref('/userProfile');
  15.  
  16.   }
  17.  
  18.   getUserProfile(): any {
  19.     return this.userProfile.child(this.currentUser.uid);
  20.   }
  21.  
  22.   updateName(firstName: string, lastName: string): any {
  23.     return this.userProfile.child(this.currentUser.uid).update({
  24.       firstName: firstName,
  25.       lastName: lastName,
  26.     });
  27.   }
  28.  
  29.   updateDOB(birthDate: string): any {
  30.     return this.userProfile.child(this.currentUser.uid).update({
  31.       birthDate: birthDate,
  32.     });
  33.   }
  34.  
  35.   updateEmail(newEmail: string): any {
  36.     this.currentUser.updateEmail(newEmail).then(() => {
  37.       this.userProfile.child(this.currentUser.uid).update({
  38.         email: newEmail
  39.       });
  40.     }, (error) => {
  41.       console.log(error);
  42.     });
  43.   }
  44.  
  45.  
  46.   updatePassword(newPassword: string): any {
  47.     this.currentUser.updatePassword(newPassword).then(() => {
  48.       console.log("Password Changed");
  49.     }, (error) => {
  50.       console.log(error);
  51.     });
  52.   }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement