Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- import { AngularFireDatabase } from '@angular/fire/database';
- import { AngularFireAuth } from '@angular/fire/auth';
- @Injectable()
- export class UsercrudProvider {
- user;
- constructor(private db: AngularFireDatabase, private afireAuth: AngularFireAuth) {
- console.log('Hello UsercrudProvider Provider');
- }
- addUser(newuser) { // user registration
- return this.afireAuth.auth.createUserWithEmailAndPassword(newuser.email, newuser.password).then(async res => {
- await this.db.object(`userprofile/${res.user.uid}`).set({
- uid: this.afireAuth.auth.currentUser.uid,
- displayName: newuser.level,
- email: newuser.email,
- address: newuser.address,
- phoneNumber: newuser.phonenumber,
- FullName: newuser.name,
- photoURL: 'https://firebasestorage.googleapis.com/v0/b/foodapp-ab746.appspot.com/o/icon%2Fuser.png?alt=media&token=eafabe55-2727-4c87-a4f2-4f172d427ca4'
- });
- this.user = res.user;
- });
- }
- getUserDetails() {
- return this.db.object(`userprofile/${this.user.uid}`).valueChanges();
- }
- updateProfilePic(photoURL) { // store profilepic from storage to db
- return this.db.object(`userprofile/${this.user.uid}`).update({
- photoURL
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement