Skip to content

Instantly share code, notes, and snippets.

@ShekMak
Last active September 26, 2021 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShekMak/0fa2662a76f07f8d08913633b5f93a02 to your computer and use it in GitHub Desktop.
Save ShekMak/0fa2662a76f07f8d08913633b5f93a02 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/compat/auth';
import firebase from '@firebase/app-compat';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AuthService {
constructor(private angularFireAuth: AngularFireAuth) { }
getCurrentUser(): Observable<any> {
return this.angularFireAuth.authState;
}
signUpWithEmailAndPassword(email: string, password: string): Promise<any> {
return this.angularFireAuth.createUserWithEmailAndPassword(email, password);
}
signInWithEmailAndPassword(email: string, password: string): Promise<any> {
return this.angularFireAuth.signInWithEmailAndPassword(email, password);
}
signInWithProvider(provider: any): Promise<any> {
return this.angularFireAuth.signInWithRedirect(provider);
}
signInWithGoogle(): Promise<any> {
return this.signInWithProvider(new firebase.auth.GoogleAuthProvider());
}
signOut(): Promise<any> {
return this.angularFireAuth.signOut();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment