Friday, May 10, 2024
HomeCSSHow am i able to remedy this error? this.authserv.getUser() isn't a perform

How am i able to remedy this error? this.authserv.getUser() isn’t a perform


error message

import { Injectable } from '@angular/core'; <br>
import {  signInWithEmailAndPassword , Auth, authState ,
createUserWithEmailAndPassword, updateProfile  } from '@angular/hearth/auth';<br>
import { AngularFireAuth } from '@angular/hearth/compat/auth';<br>
import { switchMap  } from 'rxjs';<br>
import { from, map  ,Observable } from 'rxjs';<br>
import firebase from 'firebase/compat/app';<br>
import { UserInfo } from '../fashions/user-info';<br>
import { UserService } from './person.service';<br>

@Injectable({<br>
   providedIn: 'root'<br>
})

export class AuthService {<br>

   isLoggedIn:boolean = false<br>
   currentUser$ = authState(this.afAuth);<br>
   person$!:Observable<firebase.Consumer | any ><br>
  
  constructor(<br>

      public afAuth:Auth ,<br>
      non-public ath:AngularFireAuth,<br>
      non-public userserv:UserService<br>

      ) {

    this.person$ = ath.authState

   }

  login(electronic mail:any, password:any){

    return from(signInWithEmailAndPassword(this.afAuth , electronic mail, password))

    }

    logout(){

      return from(this.afAuth.signOut())

    }

    signup(identify:any , electronic mail:any , password:any){

      return from ( createUserWithEmailAndPassword (this.afAuth , electronic mail , password)).pipe(

        switchMap(({person})=> updateProfile(person, { displayName: identify }))

      )};

    isAuthenticated(){

      return this.isLoggedIn;

    }

    getauth(){

      return this.ath.authState.pipe(map(auth => auth));

    }

   loginwithgoogle(){

      return from (this.ath.signInWithPopup( new firebase.auth.GoogleAuthProvider()))

    }


  get AppUser$(): Observable<UserInfo |any> {

      return this.person$.pipe(switchMap(person => {

          if (person) {

            return this.userserv.getUser(person.uid).valueChanges();

          } else {

            return Observable.of(null);

          } }));

    }

  }
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments