Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. import { Injectable } from '@angular/core';
  2. import { AngularFireDatabase } from '@angular/fire/database';
  3. import { AngularFireAuth } from '@angular/fire/auth';
  4.  
  5. @Injectable()
  6. export class UsercrudProvider {
  7. user;
  8.  
  9. constructor(private db: AngularFireDatabase, private afireAuth: AngularFireAuth) {
  10. console.log('Hello UsercrudProvider Provider');
  11. }
  12.  
  13. addUser(newuser) { // user registration
  14. return this.afireAuth.auth.createUserWithEmailAndPassword(newuser.email, newuser.password).then(async res => {
  15. await this.db.object(`userprofile/${res.user.uid}`).set({
  16. uid: this.afireAuth.auth.currentUser.uid,
  17. displayName: newuser.level,
  18. email: newuser.email,
  19. address: newuser.address,
  20. phoneNumber: newuser.phonenumber,
  21. FullName: newuser.name,
  22. photoURL: 'https://firebasestorage.googleapis.com/v0/b/foodapp-ab746.appspot.com/o/icon%2Fuser.png?alt=media&token=eafabe55-2727-4c87-a4f2-4f172d427ca4'
  23. });
  24. this.user = res.user;
  25. });
  26. }
  27.  
  28. getUserDetails() {
  29. return this.db.object(`userprofile/${this.user.uid}`).valueChanges();
  30. }
  31.  
  32. updateProfilePic(photoURL) { // store profilepic from storage to db
  33. return this.db.object(`userprofile/${this.user.uid}`).update({
  34. photoURL
  35. });
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement